Arc Forumnew | comments | leaders | submitlogin
(/ 0 0.0) = 0
5 points by drcode 5928 days ago | 7 comments
Don't know if this bug has been pointed out before.

9 points by kens 5928 days ago | link

"(/ 0 0.0) = 0" is a feature. "0" is exact 0, and "0." is "inexact 0". And something that's exactly zero divided by something that's not exactly zero is 0. There's also "-0." which is inexact negative 0. You've also got inexact infinities and inexact NaN's. If you divide a positive number by inexact negative 0, you get inexact negative infinity, and the other sign combinations work as you'd expect.

I should point out that I'm not making this up :-) See page 13 of the MzScheme manual:

For comparison of infinities in different versions of Scheme (more than you ever wanted to know):


2 points by drcode 5927 days ago | link

wow- I never would have expected that... It seems that anyone who has a computer program dividing by zero would want an exception raised or at least have an NaN generated. Generating "0" makes no sense- In my scenario, for instance, the function limit was towards 1, so generating a zero is mathematically seemingly completely nonsensical.... Thanks for straightening me out, kens :-)


5 points by stefano 5927 days ago | link

In floating point arithmetic 0.0 isn't zero: it represent a range of numbers around zero, so it makes a little sense for 0/0.0 to return 0.0. I still think that raising an exception would be preferable.


6 points by cchooper 5927 days ago | link

To be pedantic, it doesn't make any sense to return 0.0, but it does make some sense to return 0. I'm sure that's what you meant though.

It's 0.0/0.0 that gets my head spinning. If only 'Whatever' were a valid number.


4 points by Jesin 5925 days ago | link

Well, it depends.

  lim{x -> 0}(x/x) = 1
  lim{x -> 0}(x/0) = NaN
  lim{x -> 0}(0/x) = 0


2 points by dreish 5926 days ago | link

Considering this is a property of Scheme, what are the odds that it would really be a bug? Not to say that Scheme is perfect in every way, but I'm pretty sure they've thought through basic arithmetic.


2 points by cooldude127 5928 days ago | link

screwy floating point arithmetic!