☰
  • 首页
  • 规则分类
  • 项目介绍
search
•••

整数类型转为浮点类型时,浮点类型无法存储整数的值

C++-Undefined-Behavior-27
目录 › next › previous

示例:

long n = 1234567890L;
float f0 = n;            // Cannot be represented exactly
double f1 = n;           // OK

例中 1234567890 无法被 float 变量存储,但可被 double 变量存储。

依据

ISO/IEC 14882:2011 4.9(2)-undefined

规则

ID_narrowCast
Copyright©2024 360 Security Technology Inc., Licensed under the Apache-2.0 license.