A Bug in Math.IEERemainder?

  • Thread starter Thread starter Sunny S
  • Start date Start date
S

Sunny S

Hi,



When calculating a remainder, R, as a result of X / Y, you wouldn't expect R
to be greater than Y, right? Wrong!



Math.IEEERemainder( double.MaxValue, 1000.0 ) returns 1.99584030953472E+292.
I understand why and how this happens, but the point is that returning a
value that is greater than the divisor, 1000.0, is completely wrong and no
reason could be used as an excuse.



Incidentally, Math.IEEERemainder( double.MaxValue, 100.0 ) returns 0.0 as
expected.



Sunny S
 
Sunny S said:
When calculating a remainder, R, as a result of X / Y, you wouldn't expect R
to be greater than Y, right? Wrong!

Math.IEEERemainder( double.MaxValue, 1000.0 ) returns 1.99584030953472E+292.
I understand why and how this happens, but the point is that returning a
value that is greater than the divisor, 1000.0, is completely wrong and no
reason could be used as an excuse.

Incidentally, Math.IEEERemainder( double.MaxValue, 100.0 ) returns 0.0 as
expected.

This appears to be fixed in .NET 2.0 beta 2 - at least, the above
returns 368, which I believe to be correct.
 
Thanks, Jon. 368 is ok At least it looks like a reasonable trade-off between
accuracy and performanceJ



Sunny S.
 
Sunny S said:
Thanks, Jon. 368 is ok At least it looks like a reasonable trade-off between
accuracy and performanceJ

368 is better than okay though - I believe it's the exactly correct
value, given the output of my DoubleConverter which shows the *exact*
value of any double.
 
Back
Top