Conversion to orfrom an integer type produces a value outside the range that can be represented(6.3.1.4).

Demotion of onereal floating type to another produces a value outside the range that can berepresented (6.3.1.5).

  如果一个浮点数转换成整数,小数部分会被丢弃。如果浮点数的整数部分越界了,那么undefined behavior

  如果一个整数转换到浮点数,没有越界但是浮点数无法精确表示这个整数,那么取最近的一个值(或高或低),这是实现相关的(implementation-definedmanner).

  如果一个整数转换到浮点数,越界了,那么undefined behavior

  浮点数与浮点数之间的转换也有类似的规则。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-02
  • 2021-12-15
  • 2021-08-15
  • 2021-05-02
猜你喜欢
  • 2021-11-28
  • 2022-02-11
  • 2022-03-08
  • 2021-08-17
  • 2021-08-15
  • 2021-10-20
  • 2021-11-30
相关资源
相似解决方案