Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

how to round up decimal values


i have a label and textbox with text amount,according to my scenarion what ever the value enter into textbox it should round up to 2 decimal values.

for example if end user enters 1234.432 then it should be 1234.43,if enduser enters 3456.45678 then it should be 3456.46

can u pleas esend me the required code for this



Former Member
Former Member replied


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

0 View this answer in context

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question