I have several floating point values in processing with decimal places beyond 8 digits.
How can I round these values to the tenths before using text()
to draw them?
You can format a floating point (float
or double
) x
with 2 decimal places like this:
String.format("%.2f", x)
This'll give you a String
.
For example:
String.format("%.2f", 12.34567)
returns the string "12.35"
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With