• Post Reply Bookmark Topic Watch Topic
  • New Topic

Math , round number  RSS feed

 
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if I have 11.123456789999, I need to round it to 10 decimal . So what data I should get? 11.1234567899 or 11.1234567900 ?

Thanks.
 
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on what rounding mode you want to use (see BigDecimal). But applying a round method from java.lang.Math, I would expect to get 11.1234567900 after adjusting (and formatting) for 10 decimal places.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!