相关疑难解决方法(0)

与float和float文字相比较的奇怪输出

float f = 0.7;
if( f == 0.7 )
    printf("equal");
else
    printf("not equal");
Run Code Online (Sandbox Code Playgroud)

为什么输出not equal

为什么会这样?

c c++ floating-point double-precision

34
推荐指数
3
解决办法
6725
查看次数

比较浮点值

我刚刚阅读了有关浮点值比较的声明

不能使用==或!=运算符比较浮点值.大多数浮点值没有精确的二进制表示,并且精度有限.

如果是这样,比较两个浮点值的最佳方法是什么?

.net c# floating-point comparison

6
推荐指数
1
解决办法
4436
查看次数

标签 统计

floating-point ×2

.net ×1

c ×1

c# ×1

c++ ×1

comparison ×1

double-precision ×1