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

round problem

Former Member
0 Likes
671

hi experts

hi do i round a number allways down e.g. 24.9 will be 24 and 24.3 also will be 24

thanks

amit

1 ACCEPTED SOLUTION
Read only

JozsefSzikszai
Active Contributor
0 Likes
655

hi Amit,

you can use:

number = FLOOR( number ).

hope this helps

ec

5 REPLIES 5
Read only

JozsefSzikszai
Active Contributor
0 Likes
656

hi Amit,

you can use:

number = FLOOR( number ).

hope this helps

ec

Read only

Former Member
0 Likes
655

Hi,

use ceil()

a = ceil( 24.3 ).

write:/ a.

output :24

Regards

Read only

former_member283648
Participant
0 Likes
655

Hi,

You should use the keyword FLOOR.

Say i = 24.9

then floor(i) = 24.

Read only

Former Member
0 Likes
655

data:res type p decimals 2

res = (resuly/100) *100

store the result in res varaible

Rewards If Useful

Read only

Former Member
0 Likes
655

Hi,

If you want to round the number to the nearest integer, then you must use the function module ROUND. I am pasting you an example below:

data: nu(10) type p decimals 4.

data: nu1(5) type p decimals 2.

nu = '4.017'.

CALL FUNCTION 'ROUND'

EXPORTING

DECIMALS = 2

INPUT = nu

  • SIGN = ' '

IMPORTING

OUTPUT = nu1

  • EXCEPTIONS

  • NPUT_INVALID = 1

  • OVERFLOW = 2

*TYPE_INVALID = 3

  • OTHERS = 4

.

Write:/ nu1. output -> 4.02.

Here you must set the DECIMALS parameter to suit your purpose.

Reward if helpful.

Edited by: prosenjit chaudhuri on Feb 6, 2008 9:20 AM