Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Interesting solution for divide by 0 errors

Author
Message
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 25th May 2009 06:14
Was programming and stumbled across this method to prevent divide by 0 errors.

Rather than dividing, simply multiply by the inverse, that is, the quantity raised to the power of -1. In the case of a /0 error, it will simply return 1.#INFF, instead of the error.

Observe:


Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 25th May 2009 07:26
You did'nt divide by 0 you divide 5 into 0

If at first you don't succeed-Pause-Go to last checkpoint
That1Smart Guy
16
Years of Service
User Offline
Joined: 26th Feb 2009
Location: Somewhere...... yep
Posted: 25th May 2009 07:44
that the INVERSE of it, meaning the reciprocal (the reciprocal of a fraction in a/b is b/a) if im reading that right

There are only 10 kinds of people in the world, those who understand binary and those who dont
BN2 Productions
21
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 25th May 2009 07:57
Thats correct smart guy. The first part is to see that the inversion idea WORKS, that is, (5/2)^(-1)=2/5=.4 . The second set is to show that the divide by 0 error, that is (0/5)^(-1)=5/0 doesn't occur.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
t10dimensional
16
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 25th May 2009 08:14 Edited at: 25th May 2009 08:17
O,got ya.sry

and I just got done doing my algebra2 final on that stuff,lol.

If at first you don't succeed-Pause-Go to last checkpoint

Login to post a reply

Server time is: 2025-06-08 09:22:58
Your offset time is: 2025-06-08 09:22:58