Re:John Gustafson’s crusade to replace floating point with s...
by desdiv on Tuesday July 09, 2019 @02:19AM
(#20389408)
Yes, that's a hard bug to catch, but if the mantra of "every floating point comparison must use a context-appropriate epsilon" is followed, then it wouldn't have happened in the first place.
Re:John Gustafson’s crusade to replace floating point with s...
by stkdump on Tuesday July 09, 2019 @08:00AM
(#20390910)
I hate that mantra, as it produced more bugs and inaccuracies in the code I have to work with than necessary. Actually you should be able to rely on the equality of a value with its copy no matter what. We are past the FPU days, so I think we can let go of these mindless epsilons sprinkled over the code.
(Even during the FPU days, every ; should have rounded each value to the size of the variables, unless you use a special compiler switch to make FP math faster)
Re:John Gustafson’s crusade to replace floating point with s...
by martinpw on Tuesday July 09, 2019 @02:32AM
(#20389455)
Absolutely, and the fix involved adding a tolerance check. Not my code, I was the new guy at the time, and my job was trying to fix the bugs nobody else wanted to deal with...
Re:John Gustafson’s crusade to replace floating point with s...
by pvg on Tuesday July 09, 2019 @01:51AM
(#20389296)
Nothing in between the assignment and the check changed the value of x or y
What was the check for?
I spent a long time once debugging an issue arising from this. Code was basically:
Nothing in between the assignment and the check changed the value of x or y, yet the check triggered the fail condition. Turned out to be that one of the value stayed in the 80 bit x87 register and one was written to RAM as a 64 bit value, then loaded back into an x87 register for the check, resulting in the inequality. Running in a debugger wrote both values out of the registers before the check, making the problem unreproducible.