Java: Calculations returning wrong answer?

> **Possible Duplicate:** > [Retain precision with Doubles in java]( > [Moving decimal places over in a double]( For example, something as simple as this: public class WrongAnswer { public static void main(String[] args) { System.out.println(100*1.1); } } prints 110.00000000000001 instead of 110. Using other numbers instead of 100*1.1 also give a lot of digits with some random digit at the end that isn't right.. Any ideas?
welcome to the wonderful world of floating point numbers, where everything is approximate and the decimals don't matter.

以上就是Java: Calculations returning wrong answer?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准