Hi,
I've written an app that receives real time stock price information via TCP/IP. The app receives strings in the form '5.9300000000000000e+02' and attempts to convert them to floating point numbers using the Delphi function
'StrToFloat'.
In the live version of the application, several thousands of these conversions were performed successfully. In the newest development version, I have integrated a third party component called UCalc ( which does some formula parsing. Since I integrated this component, the StrToFloat function fails occasionally on what look like valid strings. When a conversion fails, I catch the exception, and log the offending string to a text file. From here, I cut and paste the string into a harness
application and attempt to convert it again. It succeeds. I'm satisfied that the string represents a valid floating point number.
I have discussed the problem with the author of UCalc, and we're trying a few things, but nothing seems to work. I was wondering if you guys had any ideas on what the problem is?
Here's the offending code:
try
frmLog.LogMessage('Word: ' + IntToStr(Default8087CW));
BestBid := StrToFloat(BestBidStr);
except
on E: EConvertError do
begin
frmLog.LogMessage('Length of BidStr is ' + IntToStr (Length(BestBidStr)));
frmLog.LogMessage('ODF Conversion Error: ' + BestBidStr);
end;
end;
... and here's the log file:
Word: 4914
Length of BidStr is 22
ODF Conversion Error: 1.2700000000000000e+02
As you can see, there are no UCalc specific functions to be seen - I only bring it up because it's really the only change between the live and development versions.
Any suggestions greatly appreciated.
gleNN
I've written an app that receives real time stock price information via TCP/IP. The app receives strings in the form '5.9300000000000000e+02' and attempts to convert them to floating point numbers using the Delphi function
'StrToFloat'.
In the live version of the application, several thousands of these conversions were performed successfully. In the newest development version, I have integrated a third party component called UCalc ( which does some formula parsing. Since I integrated this component, the StrToFloat function fails occasionally on what look like valid strings. When a conversion fails, I catch the exception, and log the offending string to a text file. From here, I cut and paste the string into a harness
application and attempt to convert it again. It succeeds. I'm satisfied that the string represents a valid floating point number.
I have discussed the problem with the author of UCalc, and we're trying a few things, but nothing seems to work. I was wondering if you guys had any ideas on what the problem is?
Here's the offending code:
try
frmLog.LogMessage('Word: ' + IntToStr(Default8087CW));
BestBid := StrToFloat(BestBidStr);
except
on E: EConvertError do
begin
frmLog.LogMessage('Length of BidStr is ' + IntToStr (Length(BestBidStr)));
frmLog.LogMessage('ODF Conversion Error: ' + BestBidStr);
end;
end;
... and here's the log file:
Word: 4914
Length of BidStr is 22
ODF Conversion Error: 1.2700000000000000e+02
As you can see, there are no UCalc specific functions to be seen - I only bring it up because it's really the only change between the live and development versions.
Any suggestions greatly appreciated.
gleNN