i have a double number which is "547.123456"
i just want to use this double as "547.1" like only 1 number after "."
How can i do that?
Use BigDecimal
double f=547.123456;
BigDecimal d=new BigDecimal(f);
System.out.print( d.setScale(1, RoundingMode.FLOOR));
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