Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Convert float -> string (hex) -> float fails

Moderators: kris

Posted: 08/08/11 13:48:56

Is Tango supposed to be able to convert a float to a string, formatted as hexadecimal, and then back to a float? The assert in the code below fails.

float a = 3.55f;
auto str = Format("{:x}", a);
auto b = to!(float)(str);
assert(a == b);
Author Message

Posted: 08/09/11 17:37:24

it ought to, yes (though it will be limited to 64bits ~ no 80bit reals)

Posted: 08/12/11 12:16:35

Ok, since it doesn't I'll report a bug. Thanks.