News for hackers. Stuff that matters.
Re:Mean of two floating point numbers can be dangerous by bnolsen on Sunday June 05, 2016 @11:10AM (#11841361)
to be robust you need to deal with overflow and underflow and also pesky differences in domain.

overflow breaks (x + y) / 2. where x and y are large underflow breaks (x / 2.) + (y / 2.) where x and y are small.

and of course the problem where x is outside the exponent of y. But one of these values gets treated as though it were insignificant and effectively 0.

Re:Mean of two floating point numbers can be dangerous by Scea91 on Sunday June 05, 2016 @12:43PM (#11841771)
I think that it is necessary to make a compromise between absolute robustness and readability, maintainability etc.

I hope that the input to the program is sensible enough that floating point overflow won't be an issue, since there are more complicated formulas in the program than this simple one.