News for hackers. Stuff that matters.
Re:GCC Non-bugs by dietrichepp on Monday March 02, 2015 @12:52AM (#9130497)
The result of the computation 1/3 in JS results in a number which is terminating, but that number is not 1/3. Open up your console and type 1/3+1/3+1/3... 1, as expected. Then type 1-1/3-1/3-1/3... I get about 1e-16, which is not 0.

The statement that "1/3 is terminating" is not true in binary, it is not true in decimal, and the only reason that you sometimes get the expected results is that sometimes the rounding errors will cancel out.

Re:GCC Non-bugs by shortstuffsushi on Monday March 02, 2015 @11:59AM (#9132854)
I realize that 1/3 is not terminating in decimal, what I meant was that in JS, it seemed to end neatly after x decimal places, which I found interesting. I hadn't tried the operation you mentioned until you posted that, the results are even more bizarre to me. Seems I need to spend some time relearning floating point math to better understand what I'm seeing.
Re:GCC Non-bugs by valleyer on Monday March 02, 2015 @02:52AM (#9130796)
So you're telling me we should use base 3.
Re:GCC Non-bugs by jakobegger on Monday March 02, 2015 @03:29AM (#9130909)
Well then 0.5 would be non-terminating...