3 ms·
Sometimes I wish one could configure REPLs, for example, to print floats not as the shortest input which maps to that float ("0.1"), but the actual number repre
by FabHK 7y ago
Sometimes I wish one could configure REPLs, for example, to print floats not as the shortest input which maps to that float ("0.1"), but the actual number represented by the float ("0.1000000000000000055511151231257827021181583404541015625") by default.
Somewhat annoying, but might avoid a lot of confusion ("Is floating point math broken?", https://stackoverflow.com/questions/588004/is-floating-point-math-broken https://stackoverflow.com/questions/588004/is-floating-point... ).
- klodolph 7y agoWould you like 1e-100 to print as 1.00000000000000001999189980260288361964776078853415942018260300593659569925554346761767628861329298958274607481091185079852827053974965402226843604196126360835628314127871794272492894246908066589163059300043457860230145025079449986855914338755579873208034769049845635890960693359375e-100?
- FabHK 7y agoNice example! Makes sense that it can get quite long, though it was not present in my mind. But, hey, that's what the number represented actually is. As I said, make it optional...
- firethief 7y agoIMO hex should be the default representation of binary fp. Printing hex gives the exact value, without giving the illusion of having precision in the hundreds of digits, and can be done way faster than conversion to decimal. >>> 0.1.hex() 0x1.999999999999ap-4 >>> 1e-100.hex() 0x1.bff2ee48e0530p-333