Daily Unreal Column #1 - Min and max for numeric types
It is quite common to assign min and max values to a numeric variables as part of their initialization. However, a lot folks don't know, that there is a structure for instant access to these.
The structure mentioned in the topic of this post is TNumericLimits<typename NumericType> and can be found in NumericLimits.h file. Subclasses of this structure implement different template parameters like uint8 or int32. They all contain same set of constexpr functions:
MinMaxLowest
Which can be accessed like this:
const int32 Foo = TNumericLimits<int32>::Max();Caution
Please notice that for integers both Min and Lowest functions return the same value. For int8 that would be -128. However, for float and double, the Min function will return the smallest possible POSITIVE value for this type, while Lowest returns the actual smallest possible value.


