Comparing IEEE floats and doubles for equality

前端 未结 15 2305
南方客
南方客 2020-11-30 06:00

What is the best method for comparing IEEE floats and doubles for equality? I have heard of several methods, but I wanted to see what the community thought.

15条回答
  •  遥遥无期
    2020-11-30 07:00

    @DrPizza: I am no performance guru but I would expect fixed point operations to be quicker than floating point operations (in most cases).

    It rather depends on what you are doing with them. A fixed-point type with the same range as an IEEE float would be many many times slower (and many times larger).

    Things suitable for floats:

    3D graphics, physics/engineering, simulation, climate simulation....

提交回复
热议问题