summaryrefslogtreecommitdiffstats
path: root/include/iprt/nocrt/limits
blob: 194aa8b5e52d8672a33bd0881c2b507f0ff48e6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
/** @file
 * IPRT / No-CRT - C++ limits header.
 */

/*
 * Copyright (C) 2022-2023 Oracle and/or its affiliates.
 *
 * This file is part of VirtualBox base platform packages, as
 * available from https://www.virtualbox.org.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, in version 3 of the
 * License.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <https://www.gnu.org/licenses>.
 *
 * The contents of this file may alternatively be used under the terms
 * of the Common Development and Distribution License Version 1.0
 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
 * in the VirtualBox distribution, in which case the provisions of the
 * CDDL are applicable instead of those of the GPL.
 *
 * You may elect to license modified versions of this file under the
 * terms and conditions of either the GPL or the CDDL or both.
 *
 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
 */

#ifndef VBOX_INCLUDED_SRC_nocrt_limits
#define VBOX_INCLUDED_SRC_nocrt_limits
#ifndef RT_WITHOUT_PRAGMA_ONCE
# pragma once
#endif

#include <iprt/nocrt/limits.h>
#include <iprt/nocrt/float.h>

namespace std
{
    enum float_denorm_style
    {
        denorm_indeterminate = -1,
        denorm_absent,
        denorm_present,
    };

    enum float_round_style
    {
        round_indeterminate = -1,
        round_toward_zero,
        round_to_nearest,
        round_toward_infinity,
        round_toward_neg_infinity,
    };

    struct rtNoCrtLimitNumericBase
    {
        static const bool is_specialized    = false;
        static const bool is_integer        = false;
        static const bool is_signed         = false;
        static const bool is_exact          = false;
        static const bool is_bounded        = false;

        static const bool has_infinity      = false;
        static const bool has_quiet_NaN     = false;
        static const bool has_signaling_NaN = false;
        static const bool has_denorm_loss   = false;
        static const bool is_iec559         = false;
        static const bool is_modulo         = false;
        static const bool traps             = false;
        static const bool tinyness_before   = false;

        static const int digits             = 0;
        static const int digits10           = 0;
        static const int max_digits10       = 0;
        static const int radix              = 0;
        static const int min_exponent       = 0;
        static const int min_exponent10     = 0;
        static const int max_exponent       = 0;
        static const int max_exponent10     = 0;

        static const float_denorm_style has_denorm = denorm_absent;
        static const float_round_style round_style = round_toward_zero;
    };

    struct rtNoCrtLimitNumericIntBase : public rtNoCrtLimitNumericBase
    {
        static const bool is_specialized    = true;
        static const bool is_integer        = true;
        static const bool is_exact          = true;
        static const bool is_bounded        = true;
        static const int radix              = 2;
    };

    struct rtNoCrtLimitNumericFloatBase : public rtNoCrtLimitNumericBase
    {
        static const bool is_specialized    = true;
        static const bool is_signed         = true;
        static const bool is_bounded        = true;
        static const bool has_infinity      = false;
        static const bool has_quiet_NaN     = false;
        static const bool has_signaling_NaN = false;
        static const bool is_iec559         = false;
        static const int radix              = FLT_RADIX;
        static const float_denorm_style has_denorm = denorm_present;
        static const float_round_style round_style = round_to_nearest;
    };

    /*
     * Generic template.
     */
    template<typename a_Type>
    struct numeric_limits : public rtNoCrtLimitNumericBase
    {
        /** @todo need a RT_CONSTEXPR_FN etc   */
        static constexpr a_Type(min)() RT_NOEXCEPT          { return a_Type(); }
        static constexpr a_Type(max)() RT_NOEXCEPT          { return a_Type(); }
        static constexpr a_Type lowest() RT_NOEXCEPT        { return a_Type(); }
        static constexpr a_Type epsilon() RT_NOEXCEPT       { return a_Type(); }
        static constexpr a_Type round_error() RT_NOEXCEPT   { return a_Type(); }
        static constexpr a_Type infinity() RT_NOEXCEPT      { return a_Type(); }
        static constexpr a_Type quiet_NaN() RT_NOEXCEPT     { return a_Type(); }
        static constexpr a_Type signaling_NaN() RT_NOEXCEPT { return a_Type(); }
        static constexpr a_Type denorm_min() RT_NOEXCEPT    { return a_Type(); }
    };

    /* const and volatile trickery:  */
    template<typename a_Type> struct numeric_limits<const a_Type>          : public numeric_limits<a_Type> {};
    template<typename a_Type> struct numeric_limits<volatile a_Type>       : public numeric_limits<a_Type> {};
    template<typename a_Type> struct numeric_limits<const volatile a_Type> : public numeric_limits<a_Type> {};

    /*
     * Integer specializations.
     */
    template<>
    struct numeric_limits<bool> : public rtNoCrtLimitNumericIntBase
    {
        static constexpr bool(min)() RT_NOEXCEPT          { return false; }
        static constexpr bool(max)() RT_NOEXCEPT          { return true; }
        static constexpr bool lowest() RT_NOEXCEPT        { return false; }
        static constexpr bool epsilon() RT_NOEXCEPT       { return false; }
        static constexpr bool round_error() RT_NOEXCEPT   { return false; }
        static constexpr bool infinity() RT_NOEXCEPT      { return false; }
        static constexpr bool quiet_NaN() RT_NOEXCEPT     { return false; }
        static constexpr bool signaling_NaN() RT_NOEXCEPT { return false; }
        static constexpr bool denorm_min() RT_NOEXCEPT    { return false; }
        static const int digits             = 1;
    };

    template<>
    struct numeric_limits<char> : public rtNoCrtLimitNumericIntBase
    {
        static constexpr char(min)() RT_NOEXCEPT          { return CHAR_MIN; }
        static constexpr char(max)() RT_NOEXCEPT          { return CHAR_MAX; }
        static constexpr char lowest() RT_NOEXCEPT        { return CHAR_MIN; }
        static constexpr char epsilon() RT_NOEXCEPT       { return 0; }
        static constexpr char round_error() RT_NOEXCEPT   { return 0; }
        static constexpr char infinity() RT_NOEXCEPT      { return 0; }
        static constexpr char quiet_NaN() RT_NOEXCEPT     { return 0; }
        static constexpr char signaling_NaN() RT_NOEXCEPT { return 0; }
        static constexpr char denorm_min() RT_NOEXCEPT    { return 0; }

        static const bool is_signed         = (char)(-1) < 0;
        static const bool is_modulo         = (char)(-1) > 0;
        static const int digits             = (char)(-1) < 0 ? CHAR_BIT - 1 : CHAR_BIT;
        static const int digits10           = 2;
    };

    template<>
    struct numeric_limits<signed char> : public rtNoCrtLimitNumericIntBase
    {
        static constexpr signed char(min)() RT_NOEXCEPT          { return SCHAR_MIN; }
        static constexpr signed char(max)() RT_NOEXCEPT          { return SCHAR_MAX; }
        static constexpr signed char lowest() RT_NOEXCEPT        { return SCHAR_MIN; }
        static constexpr signed char epsilon() RT_NOEXCEPT       { return 0; }
        static constexpr signed char round_error() RT_NOEXCEPT   { return 0; }
        static constexpr signed char infinity() RT_NOEXCEPT      { return 0; }
        static constexpr signed char quiet_NaN() RT_NOEXCEPT     { return 0; }
        static constexpr signed char signaling_NaN() RT_NOEXCEPT { return 0; }
        static constexpr signed char denorm_min() RT_NOEXCEPT    { return 0; }

        static const bool is_signed         = true;
        static const int digits             = CHAR_BIT - 1;
        static const int digits10           = 2;
    };

    template<>
    struct numeric_limits<unsigned char> : public rtNoCrtLimitNumericIntBase
    {
        static constexpr unsigned char(min)() RT_NOEXCEPT          { return 0; }
        static constexpr unsigned char(max)() RT_NOEXCEPT          { return UCHAR_MAX; }
        static constexpr unsigned char lowest() RT_NOEXCEPT        { return 0; }
        static constexpr unsigned char epsilon() RT_NOEXCEPT       { return 0; }
        static constexpr unsigned char round_error() RT_NOEXCEPT   { return 0; }
        static constexpr unsigned char infinity() RT_NOEXCEPT      { return 0; }
        static constexpr unsigned char quiet_NaN() RT_NOEXCEPT     { return 0; }
        static constexpr unsigned char signaling_NaN() RT_NOEXCEPT { return 0; }
        static constexpr unsigned char denorm_min() RT_NOEXCEPT    { return 0; }

        static const bool is_modulo         = true;
        static const int digits             = CHAR_BIT;
        static const int digits10           = 2;
    };

    /** @todo wchar_t, char8_t, char16_t, char32_t   */

    template<>
    struct numeric_limits<short> : public rtNoCrtLimitNumericIntBase
    {
        static constexpr short(min)() RT_NOEXCEPT          { return SHRT_MIN; }
        static constexpr short(max)() RT_NOEXCEPT          { return SHRT_MAX; }
        static constexpr short lowest() RT_NOEXCEPT        { return SHRT_MIN; }
        static constexpr short epsilon() RT_NOEXCEPT       { return 0; }
        static constexpr short round_error() RT_NOEXCEPT   { return 0; }
        static constexpr short infinity() RT_NOEXCEPT      { return 0; }
        static constexpr short quiet_NaN() RT_NOEXCEPT     { return 0; }
        static constexpr short signaling_NaN() RT_NOEXCEPT { return 0; }
        static constexpr short denorm_min() RT_NOEXCEPT    { return 0; }

        static const bool is_signed         = true;
        static const int digits             = CHAR_BIT * sizeof(short) - 1;
        static const int digits10           = 4;
    };

    template<>
    struct numeric_limits<unsigned short> : public rtNoCrtLimitNumericIntBase
    {
        static constexpr unsigned short(min)() RT_NOEXCEPT          { return 0; }
        static constexpr unsigned short(max)() RT_NOEXCEPT          { return USHRT_MAX; }
        static constexpr unsigned short lowest() RT_NOEXCEPT        { return 0; }
        static constexpr unsigned short epsilon() RT_NOEXCEPT       { return 0; }
        static constexpr unsigned short round_error() RT_NOEXCEPT   { return 0; }
        static constexpr unsigned short infinity() RT_NOEXCEPT      { return 0; }
        static constexpr unsigned short quiet_NaN() RT_NOEXCEPT     { return 0; }
        static constexpr unsigned short signaling_NaN() RT_NOEXCEPT { return 0; }
        static constexpr unsigned short denorm_min() RT_NOEXCEPT    { return 0; }

        static const bool is_modulo         = true;
        static const int digits             = CHAR_BIT * sizeof(unsigned short);
        static const int digits10           = 4;
    };

# if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED)
    template<>
    struct numeric_limits<wchar_t> : public rtNoCrtLimitNumericIntBase
    {
        static constexpr wchar_t(min)() RT_NOEXCEPT          { return WCHAR_MIN; }
        static constexpr wchar_t(max)() RT_NOEXCEPT          { return WCHAR_MAX; }
        static constexpr wchar_t lowest() RT_NOEXCEPT        { return WCHAR_MIN; }
        static constexpr wchar_t epsilon() RT_NOEXCEPT       { return 0; }
        static constexpr wchar_t round_error() RT_NOEXCEPT   { return 0; }
        static constexpr wchar_t infinity() RT_NOEXCEPT      { return 0; }
        static constexpr wchar_t quiet_NaN() RT_NOEXCEPT     { return 0; }
        static constexpr wchar_t signaling_NaN() RT_NOEXCEPT { return 0; }
        static constexpr wchar_t denorm_min() RT_NOEXCEPT    { return 0; }

        static const bool is_modulo         = true;
        static const int digits             = CHAR_BIT * sizeof(wchar_t);
        static const int digits10           = sizeof(wchar_t) == 2 ? 4 : 9; /** @todo ASSUMES wchar_t is either 16 or 32 bits */
    };
# endif

    template<>
    struct numeric_limits<char16_t> : public rtNoCrtLimitNumericIntBase
    {
        static constexpr char16_t(min)() RT_NOEXCEPT          { return 0; }
        static constexpr char16_t(max)() RT_NOEXCEPT          { return USHRT_MAX; }
        static constexpr char16_t lowest() RT_NOEXCEPT        { return 0; }
        static constexpr char16_t epsilon() RT_NOEXCEPT       { return 0; }
        static constexpr char16_t round_error() RT_NOEXCEPT   { return 0; }
        static constexpr char16_t infinity() RT_NOEXCEPT      { return 0; }
        static constexpr char16_t quiet_NaN() RT_NOEXCEPT     { return 0; }
        static constexpr char16_t signaling_NaN() RT_NOEXCEPT { return 0; }
        static constexpr char16_t denorm_min() RT_NOEXCEPT    { return 0; }

        static const bool is_modulo         = true;
        static const int digits             = CHAR_BIT * sizeof(char16_t);
        static const int digits10           = 4;
    };

    template<>
    struct numeric_limits<int> : public rtNoCrtLimitNumericIntBase
    {
        static constexpr int(min)() RT_NOEXCEPT          { return INT_MIN; }
        static constexpr int(max)() RT_NOEXCEPT          { return INT_MAX; }
        static constexpr int lowest() RT_NOEXCEPT        { return INT_MIN; }
        static constexpr int epsilon() RT_NOEXCEPT       { return 0; }
        static constexpr int round_error() RT_NOEXCEPT   { return 0; }
        static constexpr int infinity() RT_NOEXCEPT      { return 0; }
        static constexpr int quiet_NaN() RT_NOEXCEPT     { return 0; }
        static constexpr int signaling_NaN() RT_NOEXCEPT { return 0; }
        static constexpr int denorm_min() RT_NOEXCEPT    { return 0; }

        static const bool is_signed         = true;
        static const int digits             = CHAR_BIT * sizeof(int) - 1;
        static const int digits10           = 9;
    };

    template<>
    struct numeric_limits<unsigned int> : public rtNoCrtLimitNumericIntBase
    {
        static constexpr unsigned int(min)() RT_NOEXCEPT          { return 0; }
        static constexpr unsigned int(max)() RT_NOEXCEPT          { return UINT_MAX; }
        static constexpr unsigned int lowest() RT_NOEXCEPT        { return 0; }
        static constexpr unsigned int epsilon() RT_NOEXCEPT       { return 0; }
        static constexpr unsigned int round_error() RT_NOEXCEPT   { return 0; }
        static constexpr unsigned int infinity() RT_NOEXCEPT      { return 0; }
        static constexpr unsigned int quiet_NaN() RT_NOEXCEPT     { return 0; }
        static constexpr unsigned int signaling_NaN() RT_NOEXCEPT { return 0; }
        static constexpr unsigned int denorm_min() RT_NOEXCEPT    { return 0; }

        static const bool is_modulo         = true;
        static const int digits             = CHAR_BIT * sizeof(unsigned int);
        static const int digits10           = 9;
    };

    template<>
    struct numeric_limits<char32_t> : public rtNoCrtLimitNumericIntBase
    {
        static constexpr char32_t(min)() RT_NOEXCEPT          { return 0; }
        static constexpr char32_t(max)() RT_NOEXCEPT          { return UINT_MAX; }
        static constexpr char32_t lowest() RT_NOEXCEPT        { return 0; }
        static constexpr char32_t epsilon() RT_NOEXCEPT       { return 0; }
        static constexpr char32_t round_error() RT_NOEXCEPT   { return 0; }
        static constexpr char32_t infinity() RT_NOEXCEPT      { return 0; }
        static constexpr char32_t quiet_NaN() RT_NOEXCEPT     { return 0; }
        static constexpr char32_t signaling_NaN() RT_NOEXCEPT { return 0; }
        static constexpr char32_t denorm_min() RT_NOEXCEPT    { return 0; }

        static const bool is_modulo         = true;
        static const int digits             = CHAR_BIT * sizeof(char32_t);
        static const int digits10           = 9;
    };

    template<>
    struct numeric_limits<long> : public rtNoCrtLimitNumericIntBase
    {
        static constexpr long(min)() RT_NOEXCEPT          { return LONG_MIN; }
        static constexpr long(max)() RT_NOEXCEPT          { return LONG_MAX; }
        static constexpr long lowest() RT_NOEXCEPT        { return LONG_MIN; }
        static constexpr long epsilon() RT_NOEXCEPT       { return 0; }
        static constexpr long round_error() RT_NOEXCEPT   { return 0; }
        static constexpr long infinity() RT_NOEXCEPT      { return 0; }
        static constexpr long quiet_NaN() RT_NOEXCEPT     { return 0; }
        static constexpr long signaling_NaN() RT_NOEXCEPT { return 0; }
        static constexpr long denorm_min() RT_NOEXCEPT    { return 0; }

        static const bool is_signed         = true;
        static const int digits             = CHAR_BIT * sizeof(long) - 1;
        static const int digits10           = sizeof(long) == sizeof(int) ? 9 : 18;
    };

    template<>
    struct numeric_limits<unsigned long> : public rtNoCrtLimitNumericIntBase
    {
        static constexpr unsigned long(min)() RT_NOEXCEPT          { return 0; }
        static constexpr unsigned long(max)() RT_NOEXCEPT          { return ULONG_MAX; }
        static constexpr unsigned long lowest() RT_NOEXCEPT        { return 0; }
        static constexpr unsigned long epsilon() RT_NOEXCEPT       { return 0; }
        static constexpr unsigned long round_error() RT_NOEXCEPT   { return 0; }
        static constexpr unsigned long infinity() RT_NOEXCEPT      { return 0; }
        static constexpr unsigned long quiet_NaN() RT_NOEXCEPT     { return 0; }
        static constexpr unsigned long signaling_NaN() RT_NOEXCEPT { return 0; }
        static constexpr unsigned long denorm_min() RT_NOEXCEPT    { return 0; }

        static const bool is_modulo         = true;
        static const int digits             = CHAR_BIT * sizeof(unsigned long);
        static const int digits10           = sizeof(unsigned long) == sizeof(unsigned int) ? 9 : 19;
    };

    template<>
    struct numeric_limits<long long> : public rtNoCrtLimitNumericIntBase
    {
        static constexpr long long(min)() RT_NOEXCEPT          { return LLONG_MIN; }
        static constexpr long long(max)() RT_NOEXCEPT          { return LLONG_MAX; }
        static constexpr long long lowest() RT_NOEXCEPT        { return LLONG_MIN; }
        static constexpr long long epsilon() RT_NOEXCEPT       { return 0; }
        static constexpr long long round_error() RT_NOEXCEPT   { return 0; }
        static constexpr long long infinity() RT_NOEXCEPT      { return 0; }
        static constexpr long long quiet_NaN() RT_NOEXCEPT     { return 0; }
        static constexpr long long signaling_NaN() RT_NOEXCEPT { return 0; }
        static constexpr long long denorm_min() RT_NOEXCEPT    { return 0; }

        static const bool is_signed         = true;
        static const int digits             = CHAR_BIT * sizeof(long long) - 1;
        static const int digits10           = 18;
    };

    template<>
    struct numeric_limits<unsigned long long> : public rtNoCrtLimitNumericIntBase
    {
        static constexpr unsigned long long(min)() RT_NOEXCEPT          { return 0; }
        static constexpr unsigned long long(max)() RT_NOEXCEPT          { return ULLONG_MAX; }
        static constexpr unsigned long long lowest() RT_NOEXCEPT        { return 0; }
        static constexpr unsigned long long epsilon() RT_NOEXCEPT       { return 0; }
        static constexpr unsigned long long round_error() RT_NOEXCEPT   { return 0; }
        static constexpr unsigned long long infinity() RT_NOEXCEPT      { return 0; }
        static constexpr unsigned long long quiet_NaN() RT_NOEXCEPT     { return 0; }
        static constexpr unsigned long long signaling_NaN() RT_NOEXCEPT { return 0; }
        static constexpr unsigned long long denorm_min() RT_NOEXCEPT    { return 0; }

        static const bool is_modulo         = true;
        static const int digits             = CHAR_BIT * sizeof(unsigned long long);
        static const int digits10           = 19;
    };


    /*
     * Floating point.
     */
    template<>
    struct numeric_limits<float> : public rtNoCrtLimitNumericFloatBase
    {
        static constexpr float(min)() RT_NOEXCEPT          { return FLT_MIN; }
        static constexpr float(max)() RT_NOEXCEPT          { return FLT_MAX; }
        static constexpr float lowest() RT_NOEXCEPT        { return -(FLT_MAX); }
        static constexpr float epsilon() RT_NOEXCEPT       { return FLT_EPSILON; }
        static constexpr float round_error() RT_NOEXCEPT   { return 0.5F; }
        static constexpr float infinity() RT_NOEXCEPT      { return __builtin_huge_valf(); }
        static constexpr float quiet_NaN() RT_NOEXCEPT     { return __builtin_nanf("0"); }
        static constexpr float signaling_NaN() RT_NOEXCEPT { return __builtin_nansf("1"); }
        static constexpr float denorm_min() RT_NOEXCEPT    { return FLT_TRUE_MIN; }

        static const int digits             = FLT_MANT_DIG;
        static const int digits10           = FLT_DIG;
        static const int max_digits10       = FLT_DECIMAL_DIG;
        static const int max_exponent       = FLT_MAX_EXP;
        static const int max_exponent10     = FLT_MAX_10_EXP;
        static const int min_exponent       = FLT_MIN_EXP;
        static const int min_exponent10     = FLT_MIN_10_EXP;
    };

    template<>
    struct numeric_limits<double> : public rtNoCrtLimitNumericFloatBase
    {
        static constexpr double(min)() RT_NOEXCEPT          { return DBL_MIN; }
        static constexpr double(max)() RT_NOEXCEPT          { return DBL_MAX; }
        static constexpr double lowest() RT_NOEXCEPT        { return -(DBL_MAX); }
        static constexpr double epsilon() RT_NOEXCEPT       { return DBL_EPSILON; }
        static constexpr double round_error() RT_NOEXCEPT   { return 0.5; }
        static constexpr double infinity() RT_NOEXCEPT      { return __builtin_huge_val(); }
        static constexpr double quiet_NaN() RT_NOEXCEPT     { return __builtin_nan("0"); }
        static constexpr double signaling_NaN() RT_NOEXCEPT { return __builtin_nans("1"); }
        static constexpr double denorm_min() RT_NOEXCEPT    { return DBL_TRUE_MIN; }

        static const int digits             = DBL_MANT_DIG;
        static const int digits10           = DBL_DIG;
        static const int max_digits10       = DBL_DECIMAL_DIG;
        static const int max_exponent       = DBL_MAX_EXP;
        static const int max_exponent10     = DBL_MAX_10_EXP;
        static const int min_exponent       = DBL_MIN_EXP;
        static const int min_exponent10     = DBL_MIN_10_EXP;
    };

    template<>
    struct numeric_limits<long double> : public rtNoCrtLimitNumericFloatBase
    {
        static constexpr long double(min)() RT_NOEXCEPT          { return LDBL_MIN; }
        static constexpr long double(max)() RT_NOEXCEPT          { return LDBL_MAX; }
        static constexpr long double lowest() RT_NOEXCEPT        { return -(LDBL_MAX); }
        static constexpr long double epsilon() RT_NOEXCEPT       { return LDBL_EPSILON; }
        static constexpr long double round_error() RT_NOEXCEPT   { return 0.5L; }
#if LDBL_DIG == DBL_DIG
        static constexpr long double infinity() RT_NOEXCEPT      { return __builtin_huge_val(); }
        static constexpr long double quiet_NaN() RT_NOEXCEPT     { return __builtin_nan("0"); }
        static constexpr long double signaling_NaN() RT_NOEXCEPT { return __builtin_nans("1"); }
#else
        static constexpr long double infinity() RT_NOEXCEPT      { return __builtin_huge_vall(); }
        static constexpr long double quiet_NaN() RT_NOEXCEPT     { return __builtin_nanl("0"); }
        static constexpr long double signaling_NaN() RT_NOEXCEPT { return __builtin_nansl("1"); }
#endif
        static constexpr long double denorm_min() RT_NOEXCEPT    { return LDBL_TRUE_MIN; }

        static const int digits             = LDBL_MANT_DIG;
        static const int digits10           = LDBL_DIG;
        static const int max_digits10       = LDBL_DECIMAL_DIG;
        static const int max_exponent       = LDBL_MAX_EXP;
        static const int max_exponent10     = LDBL_MAX_10_EXP;
        static const int min_exponent       = LDBL_MIN_EXP;
        static const int min_exponent10     = LDBL_MIN_10_EXP;
    };

    /** @todo  more types  */
}

#endif /* !VBOX_INCLUDED_SRC_nocrt_limits */