Answer the question
In order to leave comments, you need to log in
Why does the 0.0 / 0.0 operation throw an error?
The book says that 0.0 / 0.0 returns the literal nan , but it gives me a "divide or mod by zero" error.
Same with the (-)n / 0.0 operations, which should have returned inf , but throws an error. What is the problem? Visual Studio 2019 Compiler.
std::cout << 0.0 / 0.0 << "\n\n";
Answer the question
In order to leave comments, you need to log in
What book says about nan? According to the C++ standard, division by zero is undefined behavior:
If the second operand is zero, the behavior is undefined,
except that if floating-point division is taking place and the type supports IEEE floating-point arithmetic
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question