1. divide by zero error

Perhaps there is an alternative to fatal errors caused by dividing by zero?

http://img220.imageshack.us/img220/6114/divzerosafety.png

useless

new topic     » topic index » view message » categorize

2. Re: divide by zero error

Kat said...

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.

new topic     » goto parent     » topic index » view message » categorize

3. Re: divide by zero error

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.

new topic     » goto parent     » topic index » view message » categorize

4. Re: divide by zero error

irv said...

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!

http://en.wikipedia.org/wiki/Wheel_theory

new topic     » goto parent     » topic index » view message » categorize

5. Re: divide by zero error

jimcbrown said...

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!

http://en.wikipedia.org/wiki/Wheel_theory

I wish I hadn't seen that.

new topic     » goto parent     » topic index » view message » categorize

6. Re: divide by zero error

euphoric said...
jimcbrown said...

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!

http://en.wikipedia.org/wiki/Wheel_theory

I wish I hadn't seen that.

Any particular reason?

new topic     » goto parent     » topic index » view message » categorize

7. Re: divide by zero error

irv said...

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!

new topic     » goto parent     » topic index » view message » categorize

8. Re: divide by zero error

jimcbrown said...
euphoric said...
jimcbrown said...

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!

http://en.wikipedia.org/wiki/Wheel_theory

I wish I hadn't seen that.

Any particular reason?

No, I'm just cross-eyed and confused now. grin

So thanks. tongue

new topic     » goto parent     » topic index » view message » categorize

9. Re: divide by zero error

euphoric said...

No, I'm just cross-eyed and confused now. grin

So thanks. tongue

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

new topic     » goto parent     » topic index » view message » categorize

10. Re: divide by zero error

jimcbrown said...
euphoric said...

No, I'm just cross-eyed and confused now. grin

So thanks. tongue

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

And one more:

http://en.wikipedia.org/wiki/Denormal_number

new topic     » goto parent     » topic index » view message » categorize

11. Re: divide by zero error

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

new topic     » goto parent     » topic index » view message » categorize

12. Re: divide by zero error

Exception handling is up coming in Euphoria's future, not 4.0, but soon.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu