‎2009 Apr 27 12:55 PM
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
‎2009 Apr 27 12:57 PM
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
‎2009 Apr 27 12:57 PM
Use thw statement
write v_amount decimals 2
Regards,
Ravi kanth Talagana
‎2009 Apr 27 12:57 PM
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
‎2009 Apr 27 1:02 PM
Hi,
Try this code ---
DATA : w_float TYPE f VALUE '1.234'.
WRITE : w_float DECIMALS 2.Regards
Pinaki