The float datatype usually has a special value for infinity, yes, but you don't usually need to test whether something is less than infinity. It's usually a safe assumption that your data is less than infinity. Not much point in testing it.
So the obvious way to test whether t is in the interval [0, inf) is to simply test whether t is greater than 0.
Check if the variable is infinitive - c++
Quote:Original post by SiCrane
They will be true if the floating point types adheres to IEC 559/IEEE 754, but this isn't required by the standard.
Which of course can also be tested for: std::numeric_limits<T>::is_iec559().
True, however, while is_iec559() returning true implies has_infinity() returns true, has_infinity() can be true without is_iec59() returning true.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement