C99 floating point intermediate results

戏子无情 提交于 2021-02-08 07:51:10

问题


As per the C99 standard:

6.3.1.8.2: The values of floating operands and of the results of floating expressions may be represented in greater precision and range than that required by the type; the types are not changed thereby.52)>

However, outside the scope of Annex F, we have:

5.2.4.2.2.7: The values of operations with floating operands and values subject to the usual arithmetic conversions and of floating constants are evaluated to a format whose range and precision may be greater than required by the type. The use of evaluation formats is characterized by the implementation-defined value of FLT_EVAL_METHOD:19)

Where FLT_EVAL_METHOD can be:

  • -1: indeterminable
  • 0: evaluate all operations and constants just to the range and precision of the type
  • 1: evaluate operations and constants of type float and double to the range and precision of the double type, evaluate long double operations and constants to the range and precision of the long double type
  • 2: evaluate all operations and constants to the range and precision of the long double type.

As such, for a conforming implementation, does FLT_EVAL_METHOD == [0, 1, 2] overrule 6.3.1.8.2? That is, explicit casts and/or type assignments are not needed to enforce a given width?

来源:https://stackoverflow.com/questions/50356941/c99-floating-point-intermediate-results

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!