Application Development and Automation 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: 
Read only

Rounding

Former Member
0 Likes
764

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
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
719

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

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.

5 REPLIES 5
Read only

suresh_datti
Active Contributor
0 Likes
719

check the fm ROUND in SE37.

~Suresh

Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
720

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

Read only

0 Likes
719

I always want to round to the upper number.

Eg , 3.7 = 4 and even 3.1 = 4.

MAdhu

Read only

Former Member
0 Likes
719

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

Read only

Former Member
0 Likes
719

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