WildThing
WildThing

Reputation: 675

In IEEE float implementation when an Overflow leads to INF, is it considered as undefined bahavior?

It's all in the Title. For example if the addition of two floats results in INF, does it generate an undefined behavior? or is this avoided in IEEE float implementation?

Upvotes: 0

Views: 229

Answers (1)

Stephen Canon
Stephen Canon

Reputation: 106167

No. There is no undefined behavior in IEEE-754 arithmetic. The result is defined to be infinity for the example in question, and it is defined to set a flag indicating that overflow occurred.

The only room for undefined behavior is if the platform in question doesn't adhere to IEEE-754. (C and C++ do not require that floating-point arithmetic follows IEEE-754)

Upvotes: 4

Related Questions