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

decimals

Former Member
0 Likes
563

Hi,

I have a float field which when displayed via write statement shows 3

decimals by default. How can i round it and show 2 decimals.

Is there any direct way. I dont want to convert it to string variable & then display.

Moderator message:

Sending the users to Guestification

Edited by: Vijay Babu Dudla on Apr 27, 2009 8:22 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
543

Hi.

If you are using float type then following piece of code might be useful for you.

Suppose your value is 1.234 and you want it to be rouded of to 1.23

float f = 1.234;

f *= 100;

f = (float)Math.round(f)/100;

.... and now f==1.23

Hope it will help you

3 REPLIES 3
Read only

Former Member
0 Likes
543

Use thw statement

write v_amount decimals 2

Regards,

Ravi kanth Talagana

Read only

Former Member
0 Likes
544

Hi.

If you are using float type then following piece of code might be useful for you.

Suppose your value is 1.234 and you want it to be rouded of to 1.23

float f = 1.234;

f *= 100;

f = (float)Math.round(f)/100;

.... and now f==1.23

Hope it will help you

Read only

Former Member
0 Likes
543

Hi,

Try this code ---

DATA : w_float TYPE f VALUE '1.234'.
WRITE : w_float DECIMALS 2.

Regards

Pinaki