Arc Forumnew | comments | leaders | submitlogin
9 points by kens 6084 days ago | link | parent

"(/ 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: http://download.plt-scheme.org/doc/371/pdf/mzscheme.pdf

For comparison of infinities in different versions of Scheme (more than you ever wanted to know): http://swissnet.ai.mit.edu/~jaffer/III/RAWI.html



2 points by drcode 6083 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 6083 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 6083 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 6081 days ago | link

Well, it depends.

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

-----