Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added test for numbers between zero and FLT_MIN

...

Consequently, in implementations that do not allow for the representation of all numbers, conversions of numbers values between zero and FLT_MIN may result in undefined behavior.

...

Code Block
bgColor#ccccff
langc
#include <limits.h>
 
void func(float f_a) {
  int i_a;

  if (f_a >= (float)INT_MAX || f_a < (float)INT_MIN || (f_a >= 0F && f_a < FLT_MIN)) {
    /* Handle error */
  } else {
    i_a = f_a;
  }
}

...