小编use*_*284的帖子

C ++双重除法和返回

我了解双打只是近似值。但是我很惊讶

double f(int x, int y)
{
    return double(x)/y;
}
Run Code Online (Sandbox Code Playgroud)

double f(int x, int y)
{
    double z = double(x)/y;
    return z;
}
Run Code Online (Sandbox Code Playgroud)

可以返回不同的值。有人知道为什么吗?

c++ floating-point

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

标签 统计

c++ ×1

floating-point ×1