Re: Meaning Of error in perl
by davido (Cardinal) on Jul 08, 2014 at 06:13 UTC
|
The division operation is undefined for divisors of exactly zero. Try it on your calculator.
If that doesn't clear it up, Wikipedia ought to: Division by zero.
Consider this unbreakable relationship:
x = a / b
a = b * x
This relationship is fundamental to algebra; one expression cannot be decoupled from the other. So if x = a / 0, then x * 0 = a. If 'a' is non-zero, there is no value for 'x' that can produce a non-zero 'a' if 'b' is zero. Division by zero is undefined; it has no solution.
| [reply] [d/l] |
Re: Meaning Of error in perl
by gurpreetsingh13 (Scribe) on Jul 08, 2014 at 07:16 UTC
|
See this:
Lets assume x = y
That means 2x = 2y
That means 2*(x-y) = 1*(x-y)
Dividing by (x-y) both sides, we get 2 = 1
So, that is wrong since x = y being x-y = 0. As such division by 0 is not acceptable in Mathmatics. You can call it Infinity.
That is why that error. | [reply] |
|
x = y
or, 2x = 2y
or, 2x - 2y = 2y - 2y
or, x - y = 0
... which was the origin with the assumption of x = y of course?
| [reply] [d/l] [select] |
|
x = y
2x-x = 2y-y
2x-2y = x-y
2*(x-y) = 1*(x-y)
| [reply] |
|
|
| [reply] |
Re: Meaning Of error in perl
by thanos1983 (Parson) on Jul 08, 2014 at 12:45 UTC
|
Hello grewal7634,
It would be much easier to assist you by providing a working example of your code here. But since this is not available this is my explanation and best approach to solve your problem.
As everybody answered already with examples your error comes from dividing a number with zero.
The process can not be completed.
I assume that in your calculation somewhere you have a syntax error and you divide a number with zero. I would suggest to insert print statements at every step of your calculation so you can detect where the error is coming from.
Update,
This is the first result that I found when I insert your error on Google What does the error 'Illegal division by zero' mean?. I think you will find more information there with some code that maybe assist you to understand what is the error or how to find your error.
Hope this helps.
Seeking for Perl wisdom...on the process...not there...yet!
| [reply] |
Re: Meaning Of error in perl
by perlfan (Vicar) on Jul 08, 2014 at 14:20 UTC
|
Division by zero is undefined in any programming language (not just Perl), therefore if you have code that could produce a divisor that is 0, then you'll want to guard against that in some way. | [reply] |
|
| [reply] |
|
That's not quite true, actually. Division by zero is impossible -- that is to say, zero does not have a multiplicative inverse -- in any field or indeed any ring, but general rings can have zero divisors (i.e., there may be a non-zero element a for which there exists a non-zero element b such that ab = 0).
If n is a composite number, then the quotient ring Z/nZ (basically the same as the integers, but with addition and multiplication carried out mod n) is an easy and natural example. Suppose that n = p * q for some p and q; [p] and [q] are elements of this ring, but since we're multiplying mod n, we've got [p] * [q] = [n] = [0].
| [reply] |
|
|
|