Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

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.

#include <limits>
a = std::numeric_limits<float>::quiet_NaN();
b = std::numeric_limits<float>::signaling_NaN();

New implementation...
< >
tkoenig