How do I round a double to 5 decimal places, without using DecimalFormat
?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
You can round to the fifth decimal place by making it the first decimal place by multiplying your number. Then do normal rounding, and make it the fifth decimal place again.
Let's say the value to round is a
double
namedx
:If you want to round to 6 decimal places, let
factor
be1e6
, and so on.