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: 

quotient and remainder

Former Member
0 Kudos

experts,

if i divide a variable of type i, how to get its quotient and remainder at the same time,

if we use mod we only get remainder and if we use div we get

only quotient then how to get both the values at a time.

thanks and regards.

5 REPLIES 5

Former Member
0 Kudos

hi,

What is the Need for such operation at the same time?

Sumit Agarwal

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

So if you want the values at the same time, then put the two statements in the same line of code.

.

data: lv_value type i value 20.
data: Lv_quotient type p decimals 2.
data: lv_remainder type p DECIMALS 2.

lv_quotient = floor( lv_value / 3 ). lv_remainder = floor( lv_value mod 3 ).

write:/ lv_quotient.
write:/ lv_remainder.

Yes, I know, this is not what you were looking for, but I think that there is no way to put these two operations into one statement.

Regards,

Rich Heilman

Former Member
0 Kudos

hi check this..

for the remainder use mod operation

for the quotient use / operation

data: test type i value 9,

test1 type i value 2,

rem type i ,

quot type p decimals 2 .

rem = test mod test1 .

quot = test / test1 .

write:/ rem , quot .

Former Member
0 Kudos

diff btw div and /

Former Member
0 Kudos

hi,

Div - integer division operators

var = 3 Div 2.

var = 1.

/ - Quotient

var1 = 3 / 2.

var1 = 2.

Regards

Sumit Agarwal