10#define MI_BASE_TYPES_H
18#if defined(__has_include)
19#if (!defined(_WIN32) || (defined(_HAS_CXX20) && _HAS_CXX20) || _MSVC_LANG >= 202002L)
20#if __has_include(<bit>)
54#if defined(MI_COMPILER_MSC)
56using Sint64 =
signed __int64;
57using Uint64 =
unsigned __int64;
59#elif defined(MI_COMPILER_GCC)
66using Sint64 =
signed long long;
67using Uint64 =
unsigned long long;
88#define MI_BASE_FMT_MI_SINT64 "lld"
96#define MI_BASE_FMT_MI_UINT64 "llu"
138#define MI_BASE_FMT_MI_SIZE "llu"
146#define MI_BASE_FMT_MI_DIFFERENCE "lld"
151#define MI_PI 3.14159265358979323846
153#define MI_PI_2 1.57079632679489661923
155#define MI_PI_4 0.78539816339744830962
199 if (lhs < rhs)
return LESS;
200 else if (rhs < lhs)
return GREATER;
212{
return a < b ? a : b; }
216{
return a > b ? a : b; }
228{
return a < b ? a : b; }
230{
return a < b ? a : b; }
232{
return a < b ? a : b; }
234{
return a < b ? a : b; }
236{
return a < b ? a : b; }
238{
return a < b ? a : b; }
240{
return a < b ? a : b; }
242{
return a < b ? a : b; }
244{
return a < b ? a : b; }
246{
return a < b ? a : b; }
249{
return a > b ? a : b; }
251{
return a > b ? a : b; }
253{
return a > b ? a : b; }
255{
return a > b ? a : b; }
257{
return a > b ? a : b; }
259{
return a > b ? a : b; }
261{
return a > b ? a : b; }
263{
return a > b ? a : b; }
265{
return a > b ? a : b; }
267{
return a > b ? a : b; }
282 template <
class Target,
class Source>
295#ifdef __cpp_lib_bit_cast
296template<
class T,
class S>
297constexpr T
binary_cast(
const S& src)
noexcept {
return std::bit_cast<T,S>(src); }
299template <
class Target,
class Source>
303 Binary_cast<Target, Source> val_;
347 static T (
min)()
noexcept {
return T(); }
355 static T (
max)()
noexcept {
return T(); }
422 static Sint32 (
min)()
noexcept {
return -2147483647 - 1; }
431 static Sint64 (
min)()
noexcept {
return -9223372036854775807LL - 1LL; }
432 static Sint64 (
max)()
noexcept {
return 9223372036854775807LL; }
461 static Uint64 (
max)()
noexcept {
return 18446744073709551615ULL; }
465#ifdef MI_ARCH_BIG_ENDIAN
466# define MI__FLOAT32_INF_REP { 0x7f80, 0 }
467# define MI__FLOAT32_QNAN_REP { 0x7fc1, 0 }
468# define MI__FLOAT32_SNAN_REP { 0x7f81, 0 }
469# define MI__FLOAT64_INF_REP { 0x7ff0, 0, 0, 0 }
470# define MI__FLOAT64_QNAN_REP { 0x7ff9, 0, 0, 0 }
471# define MI__FLOAT64_SNAN_REP { 0x7ff1, 0, 0, 0 }
473#ifdef MI_ARCH_LITTLE_ENDIAN
474# define MI__FLOAT32_INF_REP { 0, 0x7f80 }
475# define MI__FLOAT32_QNAN_REP { 0, 0x7fc0 }
476# define MI__FLOAT32_SNAN_REP { 0, 0x7fa0 }
477# define MI__FLOAT64_INF_REP { 0, 0, 0, 0x7ff0 }
478# define MI__FLOAT64_QNAN_REP { 0, 0, 0, 0x7ff8 }
479# define MI__FLOAT64_SNAN_REP { 0, 0, 0, 0x7ff4 }
499 Float32_rep rep = {
MI__FLOAT32_INF_REP };
503 Float32_rep rep = {
MI__FLOAT32_QNAN_REP };
507 Float32_rep rep = {
MI__FLOAT32_SNAN_REP };
519 static Float64 (
min)()
noexcept {
return 2.2250738585072014e-308; }
520 static Float64 (
max)()
noexcept {
return 1.7976931348623158e+308; }
523 Float64_rep rep = {
MI__FLOAT64_INF_REP };
527 Float64_rep rep = {
MI__FLOAT64_QNAN_REP };
531 Float64_rep rep = {
MI__FLOAT64_SNAN_REP };
Assertions and compile-time assertions.
Configuration of the Base API.
#define mi_static_assert(expr)
Compile time assertion that raises a compilation error if the constant expression expr evaluates to f...
Definition: assert.h:58
#define MI_PREVENT_MACRO_EXPAND
Empty macro that can be used after function names to prevent macro expansion that happen to have the ...
Definition: config.h:97
static T negative_max() noexcept
Returns the smallest finite negative value for T.
Definition: types.h:363
static const bool has_signaling_NaN
Constant that is true if and only if T has a signaling NaN (not-a-number) representation.
Definition: types.h:337
static const bool has_quiet_NaN
Constant that is true if and only if T has a quiet NaN (not-a-number) representation.
Definition: types.h:331
static T infinity() noexcept
Returns an infinity value for T, if one exists, and T() otherwise.
Definition: types.h:366
static Sint64 negative_max() noexcept
LLONG_MIN.
Definition: types.h:433
static T() max() noexcept
Returns the maximum finite value for T.
Definition: types.h:355
static Sint8 negative_max() noexcept
SCHAR_MIN.
Definition: types.h:406
static const bool has_infinity
Constant that is true if and only if T has an infinity representation.
Definition: types.h:326
static const bool is_specialized
Constant that is true if and only if this traits is specialized for T.
Definition: types.h:321
static Sint16 negative_max() noexcept
SHRT_MIN.
Definition: types.h:415
static T() min() noexcept
Returns the minimum finite value for T (and for floating point types the minimum positive value).
Definition: types.h:347
static T quiet_NaN() noexcept
Returns a quiet NaN value for T, if one exists, and T() otherwise.
Definition: types.h:369
static Float64 negative_max() noexcept
-DBL_MAX
Definition: types.h:521
static Float32 negative_max() noexcept
-FLT_MAX
Definition: types.h:497
static T signaling_NaN() noexcept
Returns a signaling NaN value for T, if one exists, and T() otherwise.
Definition: types.h:372
static Sint32 negative_max() noexcept
INT_MIN.
Definition: types.h:424
unsigned long long Uint64
64-bit unsigned integer.
Definition: types.h:62
long long Sint64
64-bit signed integer.
Definition: types.h:61
static const Difference DIFFERENCE_MIN_VALUE
The minimum value for Difference.
Definition: types.h:124
Target binary_cast(Source const &val)
Cast an immutable 'Source' value to an immutable 'Target' value.
Definition: types.h:300
short Sint16
16-bit signed integer.
Definition: types.h:45
unsigned char Uint8
8-bit unsigned integer.
Definition: types.h:47
int Sint32
32-bit signed integer.
Definition: types.h:46
static const Size SIZE_MAX_VALUE
The maximum value for Size.
Definition: types.h:118
unsigned short Uint16
16-bit unsigned integer.
Definition: types.h:48
Comparison_result three_valued_sign(T t)
Returns the three valued sign for a numerical type T.
Definition: types.h:184
float Float32
32-bit float.
Definition: types.h:51
Comparison_result operator-(Comparison_result sign)
Reverses the sign of a three valued enum.
Definition: types.h:173
Comparison_result
An enum for a three-valued comparison result.
Definition: types.h:162
signed char Sint8
8-bit signed integer.
Definition: types.h:44
double Float64
64-bit float.
Definition: types.h:52
Uint64 Size
Unsigned integral type that is large enough to hold the size of all types.
Definition: types.h:103
Sint64 Difference
Signed integral type that is large enough to hold the difference of two pointers.
Definition: types.h:109
Comparison_result three_valued_compare(T lhs, T rhs)
Returns the three valued comparison result between two values of a numerical type T.
Definition: types.h:197
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
static const Difference DIFFERENCE_MAX_VALUE
The maximum value for Difference.
Definition: types.h:130
@ POSITIVE
= +1. Sign of a value is positive.
Definition: types.h:165
@ GREATER
= +1. First value is greater than second value.
Definition: types.h:169
@ EQUAL
= 0. First value is equal to second value.
Definition: types.h:168
@ NEGATIVE
= -1. Sign of a value is negative.
Definition: types.h:163
@ LESS
= -1. First value is less than second value.
Definition: types.h:167
@ ZERO
= 0. Value is zero.
Definition: types.h:164
Color abs(const Color &c)
Returns a color with the elementwise absolute values of the color c.
Definition: color.h:459
Color sign(const Color &c)
Returns the elementwise sign of color c.
Definition: color.h:743
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: example_derivatives.dox:5
Base class for the helper class to deduce properties of numeric types defined in this API.
Definition: types.h:319
Helper class to deduce properties of numeric types defined in this API.
Definition: types.h:387