C++ Builder is StrToFloat() the same as .ToDouble()

8.1k views Asked by At

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()

1

There are 1 answers

3
James Oravec On

I found enough references to answer my own question...

StrToFloat() returns an extended and an extended is a long double.

.ToDouble() returns a double.

So short answer is they are not the same, and vary as shown above.

References: