huge elapsed time for multiplication of FLT

This question already has an answer here:

  • Why does changing 0.1f to 0 slow down performance by 10x? 4 answers
  • Denormalized Numbers - IEEE 754 Floating Point 1 answer

  • The reason it takes much longer to do .9 * FLT_MIN is that the result is smaller than the smallest value a float can represent. This causes the processor to raise an exception, which is handled by the OS and may involve calling functions in user-space. That takes a long time, compared to a simple floating point multiply which is done entirely in hardware.

    How to fix it? Depends on your platform and build tools. If you are using gcc, then it tries to use CPU settings to optimize some operations, depending on what flags you set. Look at the gcc manual for -ffast-math and related floating point optimization flags. Note that the use of these flags can cause results that do not comply exactly with the IEEE floating point spec.

    链接地址: http://www.djcxy.com/p/85514.html

    上一篇: 什么是低于正常的浮点数?

    下一篇: FLT乘法的时间很长