Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Instead of RoundingMode.DOWN which class can i use in JDK1.4 version  RSS feed

 
vivekananth madhanagopalan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to round off 3 decimal value in JDK 1.4 version. Instead of RoundingMode.DOWN which class can i use in JDK1.4 version

Thanks for your reply.

Seems like set scale method in jdk1.4 would not return expected value when we pass BigDecimal argument as a "double" value.To resolve this issue we need to pass a string value



BigDecimal a = new BigDecimal(".77");
BigDecimal b = a.setScale(3, RoundingMode.DOWN);
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch
Why are you using Java1.4 which was superseded nearly ten years ago?

If you mean the rounding for BigDecimal, have you come across the numeric constants which are described as obsolete? Try them.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!