The ouput is 500. It means it just simply truncates the digits after decimal. How do I use the Decimal pattern like
"###0;-###0" to indicate it has no decimal but maintain an half-even rounding mode ? I read the DecimalFormat API and it says its default rounding mode is half-even. But it seems this rounding is not applied here.
Raj Ohadi wrote:I read the DecimalFormat API and it says its default rounding mode is half-even.
I'm an old printf() fan (String.format() works the same way BTW), and with that you'd use:but I can't help much with DecimalFormat because I'm no expert. I suspect it has far more options; with printf()/String.format() you have to accept its default rounding (whatever that is; probably half-even too).
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here