09-22-2008 7:46 AM
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
09-22-2008 7:48 AM
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
09-22-2008 7:48 AM
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
09-22-2008 7:52 AM
Hi Guatam ,
I tried those
var2 = ceil( 121.001 )
it is returning 121.
i want that to be 122.
Thanks
vinay
09-22-2008 7:48 AM
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
09-22-2008 7:52 AM
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
09-22-2008 7:54 AM
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
09-22-2008 8:26 AM
Thanks All ,
The ceil and Floor function dint work ,
it works only the way Dieter s suggested , Thanks Dieter .
Regards
Vinay kolla