harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pons Rudy <rudy.p...@etu.u-bordeaux1.fr>
Subject [classlib][luni] Formatter: BigDecimal differences from RI
Date Sat, 12 Jun 2010 17:54:31 GMT
I'm working on rounding errors when using DecimalFormat, and have seen  
a difference from RI. I think this is a RI bug:
When using, for example, System.out.printf("%.6f", new  
no rounding will be performed, and 0.12345678 will be displayed on RI.  
However, on Harmony, 0.123457 will be print. I see no reason for not  
rounding when using BigDecimal, so I think we should keep this  
behaviour. Current unit tests only use integral BigDecimal, so I will  
add tests after answer to my question.
I have another problem with BigDecimal : BigDecimal does not seem to  
keep trace of negative or positive zero. So System.out.printf("%f",  
new BigDecimal("-0.0")); will print 0.0, both on RI and Harmony. But,  
if we round BigDecimal in printf, do you think the result of  
System.out.printf("%.6f", "-0.00000012345"); should be 0.000000 or  
-0.000000 ?

View raw message