I'm working in a XE6 project, but this may apply to other version of builder as well.
I'm looking at a function name, which I think may be misleading. I'm curious if StrToFloat()
returns a float
or if it returns a double
. I found an alternative, which is .ToDouble()
but we have a bunch of references in our code already that uses StrToFloat()
. I wish to verify that I'm getting the proper precision that doubles offer.
I've done a couple tests like:
UnicodeString temp = "1234567890.12345678901234567890";
double a = StrToFloat(temp);
double b = temp.ToDouble();
These seem to give the same values from the tests I've done, but I wish to verify the StrToFloat()
is the same as .ToDouble()
I found enough references to answer my own question...
StrToFloat()
returns anextended
and an extended is along double
..ToDouble()
returns adouble
.So short answer is they are not the same, and vary as shown above.
References:
StrToFloat()
: http://docwiki.embarcadero.com/Libraries/XE6/en/System.SysUtils.StrToFloatExtended
: http://docwiki.embarcadero.com/Libraries/XE6/en/System.Extended.ToDouble()
: http://docwiki.embarcadero.com/Libraries/XE2/en/System.UnicodeString.ToDoublelong double
are more precise thendouble
precision. http://en.wikipedia.org/wiki/Long_double