# Rounding up a float value

Akshata Alandker

Greenhorn

Posts: 19

santhosh varala kumar

Greenhorn

Posts: 25

posted 3 years ago

I'm not sure what "math.ceil" is...did you write that yourself? Or did you mean "Math.ceil"?

If the former, I don't know what to tell you. If the latter, then reading the API would tell you:

Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer.

perusing the rest of the Math API would let you find the round() method.

If the former, I don't know what to tell you. If the latter, then reading the API would tell you:

Returns the smallest (closest to negative infinity) double value that is greater than or equal to the argument and is equal to a mathematical integer.

perusing the rest of the Math API would let you find the round() method.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors

Akshata Alandker

Greenhorn

Posts: 19

Campbell Ritchie

Sheriff

Posts: 48652

56

posted 3 years ago

Beware of round(). Read its documentation carefully to find what it actually does.

You might want to display the numbers rounded rather than rounding their values. In which case I suggest you look at the % tags, which you can find in the Java Tutorials if you search with ctrl‑F‑formatting. Also look in the Formatter class, but the link covers about 30 pages!

You might want to display the numbers rounded rather than rounding their values. In which case I suggest you look at the % tags, which you can find in the Java Tutorials if you search with ctrl‑F‑formatting. Also look in the Formatter class, but the link covers about 30 pages!