|
Formatting a BigDecimal Friday, February 03, 2006
Ok, this one is just me being stupid.
2 Comments:It took me slightly longer to figure out how to apply a format to a BigDecimal than it should have. solution: using java.math.BigDecimal and java.text.DecimalFormat.Feel free to make fun of me now. <willCode4Beer/> posted at 10:58 AM permalink
Careful -- DecimalFormat uses ROUND_HALF_EVEN, whereas BigDecimal uses ROUND_HALF_UP by default. I'm currently searching for a way to change DecimalFormat to be able to use ROUND_HALF_UP. Notice that conversion from BigDecimal to double might loose some information and slightly modify the number, which might not be acceptable i.e. in financial applications. |
Contributors
Under the Wheel
emulated by a synthetic accessor method Write once debug everywhere... Breaking into entry-level Web Development Problems with Hibernate Expression.not( criterion ...
Behind the Wheel
|

