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 off

Former Member
0 Likes
983

i declared variable as ZFOR1 TYPE EKET-MENGE.i want to round off the value to the next integer.if i get the value as

2.14 or 2.64 it should be rounded to 3.if i declare it as integer it is getting rounded to nearest integer that is 2.14 to 2 and 2.64 to 3.but i want both to 3.please help.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
938

Hi,

Please refer to the below code :

Hi,

Use ceil( ) function.

Ex. a = ceil ( 398.98).

wreite:/ a.

Regards,

Subha.

Similarly floor ( ) function also,

Thanks,

Sriram POnna.

7 REPLIES 7
Read only

Former Member
0 Likes
939

Hi,

Please refer to the below code :

Hi,

Use ceil( ) function.

Ex. a = ceil ( 398.98).

wreite:/ a.

Regards,

Subha.

Similarly floor ( ) function also,

Thanks,

Sriram POnna.

Read only

0 Likes
938

how should i use ceil function?

Read only

0 Likes
938

parameters: num1(5) type p decimals 2.

data: num2(5) type p decimals 2.

num2 = ceil( num1 ).

write:/ num2.

Read only

Former Member
0 Likes
938

Hi,

Plz decl as type P.

Regards,

Neptune.M

Read only

Former Member
0 Likes
938

Hello,

This is waht you want.

DATA: WA_INPUT TYPE P DECIMALS 2,

WA_OUTPUT TYPE I."P DECIMALS 2.

DATA: STR(10),STR1(10),STR2(10).

WA_INPUT = '2.14'.

WRITE WA_INPUT TO STR.

SPLIT STR AT ',' INTO STR1 STR2.

ADD 1 TO STR1.

WRITE STR1." TO WA_INPUT.

Cheers,

Vasanth

Read only

0 Likes
938

Hello,

Try this also.

DATA: WA_INPUT TYPE P DECIMALS 2,

WA_OUTPUT TYPE I."P DECIMALS 2.

DATA: STR(10),STR1(10),STR2(10).

WA_INPUT = '2.64'.

STR1 = CEIL( WA_INPUT ).

WRITE STR1.

Cheers,

Vasanth

Read only

Former Member
0 Likes
938

data: n1 type p decimals 2,

n2 type p decimals 2,

f type p decimals 2.

n1 = '10.3'.

f = frac( n1 ).

if f >= '0.5'.

n1 = n1 + ( 1 - f ).

else.

n1 = n1 - f.

endif.

write n1.

n2 = '10.7'.

f = frac( n2 ).

if f >= '0.5'.

n2 = n2 + ( 1 - f ).

else.

n2 = n2 - f.

endif.

write n2.