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: 

Rounding

Former Member
0 Kudos

Is there any function Module that will roynd a number .

Eg

3.3 = 4,

3.6 = 4.

I have done using MOD and DIV functions but was wondering if a FM exists.

Madhu.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

If you always want to round up to the nearest whole number you can use the CEIL keyword.




data: p1 type p decimals 2 value '3.33'.
data: i type i.

i = ceil( p1 ).

write:/ i.

Regards,

Rich Heilman

5 REPLIES 5

suresh_datti
Active Contributor
0 Kudos

check the fm ROUND in SE37.

~Suresh

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

If you always want to round up to the nearest whole number you can use the CEIL keyword.




data: p1 type p decimals 2 value '3.33'.
data: i type i.

i = ceil( p1 ).

write:/ i.

Regards,

Rich Heilman

0 Kudos

I always want to round to the upper number.

Eg , 3.7 = 4 and even 3.1 = 4.

MAdhu

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try this.


data: p1 type p decimals 2 value '3.3',
      p2 type p decimals 2 value '3.7',
      i type i.
              
i = p1.
write: / i.

i = p2.
write: / i.

Regards,

Ferry Lianto

Former Member
0 Kudos

Hi,

IF You want to Round up...You have to use CEIL

If you want to Round down..You have to use the function FLOOR

THanks,

Naren