Consider
#include
int main()
{
double a = 1.0 / 0;
double b = -1.0 / 0;
double c = 0.0 / 0;
std::cout << a << b
Division by 0 is undefined behavior.
From section 5.6 of the C++ standard (C++11):
The binary
/operator yields the quotient, and the binary%operator yields the remainder from the division of the first expression by the second. If the second operand of/or%is zero the behavior is undefined. For integral operands the/operator yields the algebraic quotient with any fractional part discarded; if the quotienta/bis representable in the type of the result,(a/b)*b + a%bis equal toa.
No distinction is made between integer and floating point operands for the / operator. The standard only states that dividing by zero is undefined without regard to the operands.