3 ms·
IEEE754 defines 5 rounding modes. This one sounds like nearest, ties to even. Not all decimal values are representable as float. Depending on if you compile for
by okl 7y ago
IEEE754 defines 5 rounding modes. This one sounds like nearest, ties to even. Not all decimal values are representable as float. Depending on if you compile for x87 (80-bit internal repreaentation) or SSE (64-bit) you might get slightly different results.
- Dylan16807 7y agoThey already had the same float, though. That's not very likely if the rounding modes were different. For what it's worth, it looks like different standard libraries make different choices on whether float->string conversion cares about the current rounding mode.
- ChrisLomont 7y agoI'm well aware of that, having written at length about floating-point tricks, numerical issues, etc. The issue here is you don't know what a library that formats a float does, and is the function is not specified clearly (as in C/C++), you have zero way of knowing what you will get. Thus I said to do it yourself, using proper numerics.