1. divide by zero error
- Posted by Kat Mar 15, 2009
- 1498 views
- Last edited Mar 16, 2009
Perhaps there is an alternative to fatal errors caused by dividing by zero?
http://img220.imageshack.us/img220/6114/divzerosafety.png
useless
2. Re: divide by zero error
- Posted by jimcbrown (admin) Mar 16, 2009
- 1504 views
Perhaps there is an alternative to fatal errors caused by dividing by zero?
http://img220.imageshack.us/img220/6114/divzerosafety.png
useless
I always thought that Eu should return some sort of NaN on an attempt to divide by zero, rather than crash. I'm a minority, though.
3. Re: divide by zero error
- Posted by irv Mar 17, 2009
- 1406 views
If you divide a pie by 4, you have 4 pieces. If you divide your pie by 2, you have two pieces to distribute.
If you divide it by zero, you haven't divided it at all, so you get to eat the whole dang pie.
I see nothing wrong with that.
4. Re: divide by zero error
- Posted by jimcbrown (admin) Mar 17, 2009
- 1451 views
If you divide a pie by 4, you have 4 pieces. If you divide your pie by 2, you have two pieces to distribute.
If you divide it by zero, you haven't divided it at all, so you get to eat the whole dang pie.
I see nothing wrong with that.
To think I spent 5 years working on a theory of division by zero during middle and high school years, only to discover that what I had done had already been done - and far more completely than I had done!
5. Re: divide by zero error
- Posted by euphoric (admin) Mar 17, 2009
- 1459 views
To think I spent 5 years working on a theory of division by zero during middle and high school years, only to discover that what I had done had already been done - and far more completely than I had done!
I wish I hadn't seen that.
6. Re: divide by zero error
- Posted by jimcbrown (admin) Mar 17, 2009
- 1437 views
To think I spent 5 years working on a theory of division by zero during middle and high school years, only to discover that what I had done had already been done - and far more completely than I had done!
I wish I hadn't seen that.
Any particular reason?
7. Re: divide by zero error
- Posted by DerekParnell (admin) Mar 17, 2009
- 1406 views
If you divide a pie by 4, you have 4 pieces. If you divide your pie by 2, you have two pieces to distribute.
If you divide it by zero, you haven't divided it at all, so you get to eat the whole dang pie.
I see nothing wrong with that.
LOL ... now that is funny.
(1 / 4) * 4 = 1 (1 / 3) * 3 = 1 (1 / 2) * 2 = 1 (1 / 1) * 1 = 1 (1 / 0.5) * 0.5 = 1 (1 / 0.25) * 0.25 = 1 (1 / 0.00001) * 0.00001 = 1 (1 / 0) * 0 = 1 --- Ooops?! Multiplying by zero gives a non-zero answer!
If dividing a pie by 2 gives two pieces, then dividing by 0.5 gives what? Oh - now we have two pies - we have ended world hunger. Just divide all the food we have by a half and we double the amount of food!
8. Re: divide by zero error
- Posted by euphoric (admin) Mar 17, 2009
- 1504 views
To think I spent 5 years working on a theory of division by zero during middle and high school years, only to discover that what I had done had already been done - and far more completely than I had done!
I wish I hadn't seen that.
Any particular reason?
No, I'm just cross-eyed and confused now.
So thanks.
9. Re: divide by zero error
- Posted by jimcbrown (admin) Mar 18, 2009
- 1413 views
No, I'm just cross-eyed and confused now.
So thanks.
No problem. Here are some more randomly confusing articles about computers and math to boggle your eyes.
http://docs.sun.com/source/806-3568/ncg_goldberg.html http://en.wikipedia.org/wiki/Negative_zero http://en.wikipedia.org/wiki/NaN
10. Re: divide by zero error
- Posted by jimcbrown (admin) Mar 18, 2009
- 1440 views
No, I'm just cross-eyed and confused now.
So thanks.
No problem. Here are some more randomly confusing articles about computers and math to boggle your eyes.
http://docs.sun.com/source/806-3568/ncg_goldberg.html
And one more:
11. Re: divide by zero error
- Posted by SDPringle Mar 21, 2009
- 1353 views
Look this is just a problem of what should be done with non-sense calls or expressions:
- return an error code using the classical return found in everywhere or exception mechanism seen in java and c++?
- crash the program?
- signal an error at compile time if possible first then one of the former two if not?
They all have their advantages. I'm with you though, return an error code let the caller handle the exception with the modification of the third option above. Either way you need to check something: For the crash strategy it is before each call for bad inputs and in the return policy it can be after several calls for nonsensible outputs.
Shawn Pringle
12. Re: divide by zero error
- Posted by jeremy (admin) Mar 21, 2009
- 1320 views
Exception handling is up coming in Euphoria's future, not 4.0, but soon.
Jeremy