Write a function which tests if infinity is supported for floating point numbers (this step should be omitted for languages where the language specification already demands the existence of infinity, e.g. by demanding IEEE numbers), and if so, returns positive infinity. Otherwise, return the largest possible positive floating point number.

For languages with several floating point types, use the type of the literal constant 1.5 as floating point type.

C.F. Extreme floating point values

#include <limits> double inf() { if (std::numeric_limits<double>::has_infinity) return std::numeric_limits<double>::infinity(); else return std::numeric_limits<double>::max(); }

Content is available under GNU Free Documentation License 1.2.