Implementing single-precision division as double-precision multiplication

后端 未结 3 1041
礼貌的吻别
礼貌的吻别 2020-12-19 20:29

Question

For a C99 compiler implementing exact IEEE 754 arithmetic, do values of f, divisor of type float exist such that

3条回答
  •  余生分开走
    2020-12-19 21:27

    It's certainly not possible if non-default rounding modes are possible. For example, in replacing 3.0f / 3.0f with 3.0f * C, a value of C less than the exact reciprocal would yield the wrong result in downward or toward-zero rounding modes, whereas a value of C greater than the exact reciprocal would yield the wrong result for upward rounding mode.

    It's less clear to me whether what you're looking for is possible if you restrict to default rounding mode. I'll think about it and revise this answer if I come up with anything.

提交回复
热议问题