I want to get a minimum of float without using
std::numeric_limits<T>::lowest() [c++11]
so I intend to do the following.
-std::numeric_limits<T>::max()
can I use it like this?
Yes you can use -std::numeric_limits<T>::max(). To make sure it is safe in the future, add a unit test to your project to confirm that -std::numeric_limits<T>::max() is the same as std::numeric_limits<T>::lowest() for float and double (or whatever floating point types you are using).
If your T is actually some user- or library-defined type, it may not be safe to do this...but then your unit tests would flag it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With