I have a Double
object which looses the exact value when converted to long
value.
Double d = 1.14*100
System.out.println(d.longValue());
The above statement would print : 113
.
I want 114
to be printed.
Thanks
If you need the exact 114 value you ned to use Math.round
:
double d = 1.14*100;
System.out.println(Math.round(d));
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