第31959题 单选题
下列关于C++中浮点数相等比较的写法,正确的是?

已知double类型的浮点数a和b经过不同运算后,理论值完全相等,需判断二者实际存储值是否满足误差小于1e-6的业务相等要求。

A

if (a == b) return true;

B

if (a - b < 1e-6) return true;

C

if (abs(a - b) < 1e-6) return true;

D

if (static_cast<int>(a) == static_cast<int>(b)) return true;

程序运行统计
暂无判题统计
提交0次 正确率0.00%
答案解析