You can not divided by zero!

Kailric

Jack of All Trades
Joined
Mar 25, 2008
Messages
3,100
Location
Marooned, Y'isrumgone
I just spent over an hour trying to debug my code. Last night before I went to bed I made one last change and was goinig to test it today after I got back home from work. As it would be I totally forgot what I had changed and of course the game was crashing on me.

Needless to say it was a debuging hell and it all came down to some kind of infinate loop being created when the computer tride to complete my last equation, which was very simple (a * b / c). Except the first few times the function is called all variables are 0 and you can't divided by 0!! So when the program was told to display the result of (a * b / c) the game would crash.

When did I forget that you can't divide by zero and what flippen ****** would make such a rule to start with and put it into a codeing language? Why not just make it so that if say 6 is dvidided by zero you still have 6. Make sense to me, 6 divided by nothing is still 6!!!

Also, I'll have you know that if you have nothing (0) and you divide that by say 6... you still have nothing and there is no error!

Someone please explain the logic that is why 6/0 = error!
 
In a simple way, look at it in reverse. You can't have 0 multiplying 6 equalling to 6.

I'm not a coder but I imagine machine code follows mathematical fundamentals, even if they end up making their own crazy language.
 
Appears you missed your maths curses !

6 divided by 0.1 gives 60, 6 divided by 0.01 gives 600, ... and so on.
The result will tend to the infinite if your denominator tend to 0 ... but you can't divide by 0 itself because it's non sense and thus it's prohibited by the rules.
 
Appears you missed your maths curses !

6 divided by 0.1 gives 60, 6 divided by 0.01 gives 600, ... and so on.
The result will tend to the infinite if your denominator tend to 0 ... but you can't divide by 0 itself because it's non sense and thus it's prohibited by the rules.

Its no more nonsense than trying to multiply by 0! Seems to me knowing how code works instead of having to add a "If C != 0" statement before an equation that has the potiential to divide by 0 you would, for simplicitys sake, just make 6/0 = 6. Cause if I have 6 apples and I am going to give you each equal apples... I would say 6/2 = 3.. but what if I decide at the last second to not give you any apples cause you been fighting so now its 6/0 = I still have my six apples!

And don't you take math "courses" instead of math "curses" ha.. just messing with you cause I know I can't spell worth a d am and typos are rampent :)
 
No, your six apples just disappear by dividing them by 0. And you should know multiplication is reversible (0 times 6 is also 6 times 0) ... while division is not reversible (6/2 is not the same as 2/6).

Just sorry for my passable english.
 
Kailric you're flatly wrong. Think about it, if you have no boxes of a dozen donuts, how many donuts do you have?
( 12x0=?)
See how multiplying any number by zero leaves zero? Even in the real, real world, and how this isn't some abstract mathematical idea, it is simply a law of reality?

How many dimes (1/10ths of a dollar) go into 100 dollars?
(100/0.1=?)
How many pennies (1/100ths of a dollar) go into 100 dollars?
(100/0.01=?)
Do you notice how as you reduce the fraction you divide a value by the result grows, even in the real, real world?

To conclude: How much nothing does it take to make a keg of beer?
(15gallons/0=?)
See it's nonsense, there is no possible answer, hence it breaks down in the real world, as well as general math, and coding.
 
Dividing by Zero is such a crime that it has a hardware flag built-in in the processor itself. BTW to perform division processors keep subtracting the dividend figure out of the divided one and count the number of times it can subtract it till the divided is = 0 or less than the dividend. The fact that subtracting zero out of any figure will keep its value as it is means that the processor will enter an endless loop trying to perform the operation. This is why there is hardware flag that is turned on when a trial of dividing by zero is committed so you get a hardware exception and your application is terminated. In the time of DOS and early Windows you would have gotten the whole PC crashing on you. Also if you assume that 6/0 = 6 then what is the result for 6/1 should be? Computers are Math Machines so they have to obey math rules. Just insert this little if statement it won't harm you. Happy coding :).
 
Dividing by Zero is such a crime that it has a hardware flag built-in in the processor itself. BTW to perform division processors keep subtracting the dividend figure out of the divided one and count the number of times it can subtract it till the divided is = 0 or less than the dividend. The fact that subtracting zero out of any figure will keep its value as it is means that the processor will enter an endless loop trying to perform the operation. This is why there is hardware flag that is turned on when a trial of dividing by zero is committed so you get a hardware exception and your application is terminated. In the time of DOS and early Windows you would have gotten the whole PC crashing on you. Also if you assume that 6/0 = 6 then what is the result for 6/1 should be? Computers are Math Machines so they have to obey math rules. Just insert this little if statement it won't harm you. Happy coding :).

Hey, thanks guys for all the input. I was just somewhat upset for spending an hour trying to track down this bug. I am a very much noob at codeing and my math is rusty as heck too but thanks to all of your replys I'll definately not forget this rule in the future. And it does make sense how 6/0 = nonsense. K, nite all!
 
And nite to you to. May you have more than 8 * 0 hours of pleasant sleep (but less than 8 / 0). :crazyeye:
 
Whenever I have a line of code where the denominator would be an expression, I always (a) use a single variable to capture the value and then (b) check to make sure it isn't 0. I think every programmer has been burned by the divide by zero crash at one time.
 
Top Bottom