Tuesday, 15 September 2015

java - How can I show up to 2 decimal places without rounding off? -



java - How can I show up to 2 decimal places without rounding off? -

i want take 2 decimal places float without rounding off. eg. 4.21777 should 4.21 , not 4.22. how do this?

a simple answer:

double x = 4.21777; double y = math.floor(x * 100) / 100;

java android math

No comments:

Post a Comment