Round decimal value in java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sam Susan
    New Member
    • Jan 2012
    • 1

    Round decimal value in java

    I have a decimal value 214332.04854. If i round it it will become as 214332 or 214332.0 in double or in float.I want to round & display 2 digits after that point.
  • C CSR
    New Member
    • Jan 2012
    • 144

    #2
    Start with this:

    Code:
    x = 24.12345
    y = Math.round(yy*100)/100;
    I'm suprizes no one replied to this yet.

    Comment

    • C CSR
      New Member
      • Jan 2012
      • 144

      #3
      Sorry. Too many y's. Correction:
      Code:
      x = 24.12345
      y = Math.round(x*100)/100;

      Comment

      Working...