如果我的问题不正确,请忘记我。我是 C++ 初学者。 我刚刚用c++写了一个简单的程序 我的代码是:
#include<iostream>
using namespace std;
int main()
{
float a,b,c;
a=0;
b=-5;
c=a/b;
cout<<c;
}
当我运行此代码时,输出为 -0。 答案怎么可能是 -0 而 -0 不存在?
最佳答案
How the answer could be -0 while -0 doesn't exist?
你的假设是错误的。 -0 确实存在于 float 表示中,因此答案可以是 -0。
有关引用,请参阅 IEEE-754 标准,有关“原因”,请参阅 Branch Cuts for Complex Elementary Functions or Much Ado About Nothing's Sign Bit .
关于c++ - 答案怎么是-0?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63685496/