What value do you need to assign to a variable of type float so that you can find the maximum using it: std::numeric_limits<float>::min() or std::numeric_limits<float>::lowest() , or others?

  • one
    Find the maximum of what? - Vlad from Moscow

2 answers 2

Well, since they write about min

min returns the minimum positive normalized value

those. this is a small positive number, then if you work in the whole range - including negative numbers - it is better to use the lowest . If only positive - then 0 :)

    There is one value that will be less than the lowest returned. It:

    -std::numeric_limits<float>::infinity()

    The following code displays true :

     #include <iostream> #include <limits> int main() { std::cout << std::boolalpha << (-std::numeric_limits<float>::infinity() < std::numeric_limits<float>::lowest()) << "\n"; } 

    Before use, it makes sense to check that std::numeric_limits<float>::has_infinity == true .