Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2007 Jun : Val() vs. StrToFloat()
| Subject: | Val() vs. StrToFloat() |
| Posted by: | "Andrew Fiddian-Green" (..@dd) |
| Date: | Sat, 23 Jun 2007 17:59:52 |
Perhaps this is one for John Herbster...
Question: does Val(aString, anExtended, ...) produce the same numeric result
as anExtended := StrToFloat(aString) ?
Background: StrToFloat() uses DecimalSeparator whereas val() uses a hard
coded decimal point, and since I want the latter, I think val() is faster
for my purposes -- but I need to be sure that it is also as accurate
numerically.
Alternative A
val(aString, anExtended, dummy);
if dummy <> 0 then raise...
Alternative B
tmp := DecimalSeparator;
DecimalSeparator := '.';
anExtended := StrToFloat(aString);
DecimalSeparator := tmp;
AndrewFG