Skip to Content
avatar image
Former Member

quotient and remainder

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.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • avatar image
    Former Member
    Jul 25, 2008 at 01:45 PM

    hi,

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

    Sumit Agarwal

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 25, 2008 at 01:53 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 25, 2008 at 01:53 PM

    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 .

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 26, 2008 at 06:59 AM

    diff btw div and /

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 26, 2008 at 07:29 AM

    hi,

    Div - integer division operators

    var = 3 Div 2.

    var = 1.

    / - Quotient

    var1 = 3 / 2.

    var1 = 2.

    Regards

    Sumit Agarwal

    Add comment
    10|10000 characters needed characters exceeded