2 ms·
Getting a floating point number printed "exactly" (as in with full precision, not necessarily what people expect) is not very hard; the tricky part is, as you m
by userbinator 8y ago
Getting a floating point number printed "exactly" (as in with full precision, not necessarily what people expect) is not very hard; the tricky part is, as you mention, having the shortest possible representation and rounding it correctly, as well as making it efficient.
- bradleyjg 8y agoYou need to find the shortest number that’s closer to your target float than any other float. Then to go the other direction you just find the nearest float.