This language bar is your friend. Select your favorite languages!
Select your favorite languages :
  • Or search :

Idiom #285 Set variable to NaN

Given two floating point variables a and b, set a to a to a quiet NaN and b to a signalling NaN. Use standard features of the language only, without invoking undefined behavior.

    use, intrinsic :: ieee_arithmetic, only: IEEE_Value, IEEE_QUIET_NAN, IEEE_SIGNALING_NAN
 a = ieee_value (a, IEEE_QUIET_NAN)
 b = ieee_value (b, IEEE_SIGNALING_NAN)
a := NaN;
a = float('nan')
a = Float::NAN
let a: f64 = f64::NAN;

New implementation...
< >