Re:The most copied StackOverflow snippet of all time is flawed
by zelly on Wednesday December 04, 2019 @01:08AM
(#21699990)
I wonder what percentage of bugs in general are from people not understanding how floating points work. I think property based testing (QuickCheck) should be used whenever floats are involved. Nobody ever seems to get them right.
[ Parent
| on HN ]
Re:The most copied StackOverflow snippet of all time is flawed
by floatingatoll on Wednesday December 04, 2019 @02:05AM
(#21700208)
At least -0.0% are.
Re:The most copied StackOverflow snippet of all time is flawed
by deogeo on Wednesday December 04, 2019 @05:39AM
(#21701112)
Would QuickCheck know to try 999999 as input? Most of the possible inputs would give correct results, and those that don't, aren't very 'special', such as 0,1,-1,MAX_INT, and so on.
Re:The most copied StackOverflow snippet of all time is flawed
by mrgriffin on Wednesday December 04, 2019 @08:36AM
(#21702007)
Don't many QuickCheck-inspired libraries have special cases to ensure they generate common numbers like those? I could be misremembering, but I would have sworn I read that in the documentation of the last library I looked at (whose name escapes me).
Re:The most copied StackOverflow snippet of all time is flawed
by deogeo on Wednesday December 04, 2019 @09:25AM
(#21702370)
Sorry, I phrased myself poorly - in this case, the inputs that give incorrect output aren't very special, as opposed to 0,1,INT_MAX,...
Although including numbers such as 10^N - 1 isn't out of the question either.