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 a decimal to 1 up

Former Member
0 Kudos

Hi All ,

I need help in rounding a decimal to intezer up by one value ,

i.e 1.001 to rounded to 2 .

Thanks and regards

vinay

1 ACCEPTED SOLUTION

GauthamV
Active Contributor
0 Kudos

hi,

use these arthematic operators.

CEIL

Smallest integer value that is not less than x

FLOOR

Largest integer value that is not greater than x

TRUNC

Interger part of x

6 REPLIES 6

GauthamV
Active Contributor
0 Kudos

hi,

use these arthematic operators.

CEIL

Smallest integer value that is not less than x

FLOOR

Largest integer value that is not greater than x

TRUNC

Interger part of x

Former Member
0 Kudos

Hi Guatam ,

I tried those

var2 = ceil( 121.001 )

it is returning 121.

i want that to be 122.

Thanks

vinay

Former Member
0 Kudos

Hi,

plz try ROUND function module.

data input type p decimals 3 value '1.001'.

data output type i.

CALL FUNCTION 'ROUND'

EXPORTING

DECIMALS = 0

input = input

SIGN = '+'

IMPORTING

OUTPUT = output

  • EXCEPTIONS

  • INPUT_INVALID = 1

  • OVERFLOW = 2

  • TYPE_INVALID = 3

  • OTHERS = 4

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

write: output.

thanx .

Edited by: Dhanashri Pawar on Sep 22, 2008 9:21 AM

Former Member
0 Kudos

Hi,

Use the FM ROUND.

For up '+'

for Down '-'

space for no change in the SIGN option.

OR

FLOOR is used to round down. CEIL is used to round up.

result = floor( value1 / value2 ). " Round down.

Eg:1.03 to 1

result = ceil( value1 / value2 ). " Round up.

Eg:1.03 to 2.

Regards,

Shiva Kumar

Former Member
0 Kudos

Hi,

try this:

data: dmbtr_P type p decimals 3 VALUE '1.834'.

data: dmbtr_I type I.

*

dmbtr_i = dmbtr_p + '0.5'.

*

write: / dmbtr_p, dmbtr_i.

Regards, Dieter

0 Kudos

Thanks All ,

The ceil and Floor function dint work ,

it works only the way Dieter s suggested , Thanks Dieter .

Regards

Vinay kolla