For-loop in C++ using double breaking out one step early, boundary value not reached

后端 未结 10 666
难免孤独
难免孤独 2020-12-06 03:24

I have a simple C++ program compiled using gcc 4.2.4 on 32-bit Ubuntu 8.04. It has a for-loop in which a double variable is incremented from zero t

10条回答
  •  一向
    一向 (楼主)
    2020-12-06 03:51

    Most exact decimals do not have an exact finite representation in floating point arithmetic.

    You need to read Goldberg's What Every Computer Scientist Should Know About Floating-Point Arithmetic.

提交回复
热议问题