Floating point error in representation?

前端 未结 2 1338
滥情空心
滥情空心 2020-11-27 08:14

when i make this multiplication

0.94 * 8700

the output is

8177.999999999999

but i

相关标签:
2条回答
  • 2020-11-27 08:56

    It isn't an error. IEEE floats can't represent decimal numbers exactly.

    0 讨论(0)
  • 2020-11-27 09:00

    The specific reason in your case is that the real number 0.94 cannot be represented exactly in a double precision floating point. When you type 0.94, the actual number stored is 0.939999999999999946709294817992486059665679931640625.

    0 讨论(0)
提交回复
热议问题