Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Division by zero

rainer_hbenthal
Active Contributor
0 Kudos

Why is this not giving a dump?

i = 0.
  j = 0.
  num = i / j.

This doesnt dump too:


  num = 0 / 0.

But this dumps:

i = 1.
  j = 0.
  num = i / j.

Is this some kind of weired short cut evaluation? Or is 0/0 now defined since i finished school?

Seems that the runtime assumes that everything after 0 / is always zero. Debugging case 1 and two shows that num contains zero.

Is this behaviour documented?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hello

From SAP Help (help for key word DIVIDE 😞

Furthermore: Division by 0 is not allowed, except where 0 / 0 results in 0.

5 REPLIES 5

Former Member
0 Kudos

Hello

From SAP Help (help for key word DIVIDE 😞

Furthermore: Division by 0 is not allowed, except where 0 / 0 results in 0.

Former Member
0 Kudos

Dear Rainer ,,

Very good observation . Im doing math myself now..:)

http://www.newton.dep.anl.gov/askasci/math99/math99259.htm

//You have started with an inaccurate assumption, that is: 0/0 = infinity.

The ratio 0/0 is called "indeterminate" because it is defined in terms of

the limit (as x ---> 0) of the numerator N(x) divided by the limit

(as x --->0) of the denominator D(x). If N(x) approaches zero "faster" than

D(x) the ratio is zero. If D(x) approaches zero "faster" than N(x) the ratio

approaches infinity. They may approach zero at different, but finite, rates.

If they approach zero "at exactly the same rate" you have to apply the

test again.

Br,

Vijay.

kesavadas_thekkillath
Active Contributor
0 Kudos

The output 'infinity' leads to dump.

Basic Arithmetic.

Former Member
0 Kudos

Wikipedia gives a good example (I'm paraphrasing):

0 / 0 = X.

therefore:

X * 0 = 0

Any value of X will satisfy the equation.

Rob

0 Kudos

I found this intriguing. Because any value of X will satisfy the equation:

X = 0 / 0

I would expect that if you assign the result of the division 0 / 0 to a variable, the value of the variable would remain unchanged. so if you write a program like:

REPORT ztest LINE-SIZE 80 MESSAGE-ID 00. 
PARAMETERS: i TYPE i. 
i = 0 / 0. 
WRITE: /001 i.

I would retain its value; however, the result is always 0.

Seems like a bug to me.

Rob