What are the applications/benefits of an 80-bit extended precision data type?

前端 未结 5 857
故里飘歌
故里飘歌 2020-12-09 04:34

Yeah, I meant to say 80-bit. That\'s not a typo...

My experience with floating point variables has always involved 4-byte multiples, like singles (32 bit),

5条回答
  •  失恋的感觉
    2020-12-09 05:16

    Intel's FPUs use the 80-bit format internally to get more precision for intermediate results.

    That is, you may have 32-bit or 64-bit variables, but when they are loaded into the FPU registers, they are converted to 80 bit; the FPU then (by default) performs all calculations in 80 but; after the calculation, the result is stored back into a 32-bit or 64-bit variables.

    BTW - A somewhat unfortunate consequence of this is that debug and release builds may produce slightly different results: in the release build, the optimizer may keep an intermediate variable in an 80-bit FPU register, while in the debug build, it will be stored in a 64-bit variable, causing loss of precision. You can avoid this by using 80-bit variables, or use an FPU switch (or compiler option) to perform all calculations in 64 bit.

提交回复
热议问题