News for hackers. Stuff that matters.
Re:Formatting floating point numbers by FabHK on Friday June 14, 2019 @11:28AM (#20183757)
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... ).

Re:Formatting floating point numbers by klodolph on Friday June 14, 2019 @12:26PM (#20184250)
Would you like 1e-100 to print as

  1.00000000000000001999189980260288361964776078853415942018260300593659569925554346761767628861329298958274607481091185079852827053974965402226843604196126360835628314127871794272492894246908066589163059300043457860230145025079449986855914338755579873208034769049845635890960693359375e-100?
Re:Formatting floating point numbers by FabHK on Friday June 14, 2019 @02:19PM (#20185315)
Nice 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...

Re:Formatting floating point numbers by firethief on Friday June 14, 2019 @02:25PM (#20185374)
IMO 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