Integer division by zero

suggest change
int x = 5 / 0;    // Undefined behavior

Division by 0 is mathematically undefined, and as such it makes sense that this is undefined behavior.

However:

float x = 5.0f / 0.0f;   // +infinity on IEEE-754; otherwise undefined

Most implementations use IEEE-754. Under that format, floating-point division by zero returns NaN when the numerator is 0.0f, infinity when the numerator is positive, or -infinity when the numerator is negative. The C++ standard still classifies division by zero as undefined behavior when that format is not in effect.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents