Skip to Content
avatar image
-1
Former Member

Simple division operation in SAP sometimes works wrong?

Hi Everyone,

here you are a program, which divides 2 numbers:

---------------------------------
PROGRAM divide.

DATA: pack TYPE p DECIMALS 2,
n TYPE f VALUE '1000.5',
m TYPE f VALUE '10'.

pack = n / m.

WRITE pack.
---------------------------------

Result is 100.05 and this is wrong.
Correct result is 100.50


Where is a catch?

Our version is ECC 617

I do not believe that simple division sometimes does not really work in SAP.

Thanks,
Alex

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Nov 18, 2016 at 05:45 PM

    sorry but 1000.5 / 10 gives 100.05, not 100.50 !

    Add comment
    10|10000 characters needed characters exceeded

    • Just to double check that Alexander didn't mean the other way around (that SAP is returning 100.50) I just ran his little program in SAP and it did return 100.05 as expected. Pheww - the world is still round!

  • Nov 18, 2016 at 05:18 PM

    Do you have "fixed point arithmatic" checked/selected for your program?

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 21, 2016 at 09:00 AM

    False alarm, everything works as expected. Sorry!

    Add comment
    10|10000 characters needed characters exceeded