// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "inc.h" /* Numeric constants *****************************************************************************/ #define MIN_uint8 ((uint8) 0x00) #define MIN_uint16 ((uint16) 0x0000) #define MIN_uint32 ((uint32) 0x00000000) #define MIN_uint64 ((uint64) 0x0000000000000000) #define MIN_int8 ((int8) -128) #define MIN_int16 ((int16) -32768) #define MIN_int32 ((int32) 0x80000000) #define MIN_int64 ((int64) 0x8000000000000000) #define MAX_uint8 ((uint8) 0xff) #define MAX_uint16 ((uint16) 0xffff) #define MAX_uint32 ((uint32) 0xffffffff) #define MAX_uint64 ((uint64) 0xffffffffffffffff) #define MAX_int8 ((int8) 0x7f) #define MAX_int16 ((int16) 0x7fff) #define MAX_int32 ((int32) 0x7fffffff) #define MAX_int64 ((int64) 0x7fffffffffffffff) #define MIN_flt (1.175494351e-38F) /* min positive value */ #define MAX_flt (3.402823466e+38F) #define MIN_dbl (2.2250738585072014e-308) /* min positive value */ #define MAX_dbl (1.7976931348623158e+308) /* Numeric type traits *****************************************************************************/ /** * Helper class to map a numeric type to its limits */ template struct TNumericLimits; /** * Numeric limits for const types */ template struct TNumericLimits : public TNumericLimits { }; /** * Numeric limits for volatile types */ template struct TNumericLimits : public TNumericLimits { }; /** * Numeric limits for const volatile types */ template struct TNumericLimits : public TNumericLimits { }; template<> struct TNumericLimits { typedef uint8 NumericType; static constexpr NumericType Min() { return MIN_uint8; } static constexpr NumericType Max() { return MAX_uint8; } static constexpr NumericType Lowest() { return Min(); } }; template<> struct TNumericLimits { typedef uint16 NumericType; static constexpr NumericType Min() { return MIN_uint16; } static constexpr NumericType Max() { return MAX_uint16; } static constexpr NumericType Lowest() { return Min(); } }; template<> struct TNumericLimits { typedef uint32 NumericType; static constexpr NumericType Min() { return MIN_uint32; } static constexpr NumericType Max() { return MAX_uint32; } static constexpr NumericType Lowest() { return Min(); } }; template<> struct TNumericLimits { typedef uint64 NumericType; static constexpr NumericType Min() { return MIN_uint64; } static constexpr NumericType Max() { return MAX_uint64; } static constexpr NumericType Lowest() { return Min(); } }; template<> struct TNumericLimits { typedef int8 NumericType; static constexpr NumericType Min() { return MIN_int8; } static constexpr NumericType Max() { return MAX_int8; } static constexpr NumericType Lowest() { return Min(); } }; template<> struct TNumericLimits { typedef int16 NumericType; static constexpr NumericType Min() { return MIN_int16; } static constexpr NumericType Max() { return MAX_int16; } static constexpr NumericType Lowest() { return Min(); } }; template<> struct TNumericLimits { typedef int32 NumericType; static constexpr NumericType Min() { return MIN_int32; } static constexpr NumericType Max() { return MAX_int32; } static constexpr NumericType Lowest() { return Min(); } }; template<> struct TNumericLimits { typedef int64 NumericType; static constexpr NumericType Min() { return MIN_int64; } static constexpr NumericType Max() { return MAX_int64; } static constexpr NumericType Lowest() { return Min(); } }; template<> struct TNumericLimits { typedef float NumericType; static constexpr NumericType Min() { return MIN_flt; } static constexpr NumericType Max() { return MAX_flt; } static constexpr NumericType Lowest() { return -Max(); } }; template<> struct TNumericLimits { typedef double NumericType; static constexpr NumericType Min() { return MIN_dbl; } static constexpr NumericType Max() { return MAX_dbl; } static constexpr NumericType Lowest() { return -Max(); } };