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 of decimals

Former Member
0 Kudos

HI Experts,

I have issue in roundign of decimals. I need to round the values to 3 decimal places. But the sum of the values shud be 1.

Ex - 0.434456184, 0.483094697,0.082449119 are the three values. Their sum is 1. But if i reduce them to 3 decimal places i get only total as 0.999. If i use ROUND Funciton module i get the total as 1.001.

These values i am updating in Kp26 transaction which will allow me only 3 decimal places. Can you please help me reduce them to 3 decimal places and also not affecting the sum?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

>

TRY LIKE THIS.

Data: a type p length 16 decimals 0.

a = '.999'.

a = ceil( a ).

write:/ 'ceil', a.

a = floor( a ).

write:/ 'floor', a.

hope the above snippet makes things cleareer for u,

Regards,

Chaitanya.

4 REPLIES 4

0 Kudos

Hi,

You can do something like this :

data : a type p decimals 4,

b type p decimals 4,

c type p decimals 4,

final type p decimals 3.

a = '0.434456184'.

b = '0.483094697'.

c = '0.082449119'.

final = a + b + c.

write final. => the value is 1.

this will ensure that you get the exact value and also the output is 1.

Otherwise if you want all the values should be only 3 decimals you can check if the value is .999 then out as 1.

Regards,

Narayani

Former Member
0 Kudos

Hi Haresha,

Go to OY04 and maintain decimals as 3 there.

pls reward if helps.

cheers,

Hema.

Former Member
0 Kudos

Hi,

>

TRY LIKE THIS.

Data: a type p length 16 decimals 0.

a = '.999'.

a = ceil( a ).

write:/ 'ceil', a.

a = floor( a ).

write:/ 'floor', a.

hope the above snippet makes things cleareer for u,

Regards,

Chaitanya.