Announcement Announcement Module
Collapse
No announcement yet.
BigDecimal representation problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    Originally posted by Andreas Senft View Post
    The int argument of divide() is the rounding-mode which is used to round to the given scale (in your case the scale is 2).
    Rounding mode 2 stands for ROUND_CEILING and 3 for ROUND_FLOOR. So that makes the difference.

    Try out this:
    Code:
    BigDecimal bd = new BigDecimal(2.333d);
    System.out.println(bd.scale(2, RoundingMode.CEILING));
    System.out.println(bd.scale(2, RoundingMode.FLOOR));
    It yields 2.34 and 2.33.

    Regards,
    Andreas

    thanks the knowledge became useful

    Comment

    Working...
    X