32#ifndef FENNEC_LANG_LIMITS_H
33#define FENNEC_LANG_LIMITS_H
213 round_indeterminate = -1
214, round_toward_zero = 0
215, round_to_nearest = 1
216, round_toward_infinity = 2
217, round_toward_neg_infinity = 3
238 static constexpr bool traps =
false;
252 static constexpr TypeT
min() {
return TypeT(); }
253 static constexpr TypeT
max() {
return TypeT(); }
254 static constexpr TypeT
lowest() {
return TypeT(); }
255 static constexpr TypeT
epsilon() {
return TypeT(); }
257 static constexpr TypeT
infinity() {
return TypeT(); }
266template<>
struct numeric_limits<float>
271 static constexpr bool is_exact =
false;
275 static constexpr bool has_denorm = FLT_HAS_DENORM;
277 static constexpr bool is_iec559 = FLT_IS_IEC559;
281 static constexpr bool traps = FLT_TRAPS;
283 static constexpr int digits = FLT_MANT_DIG;
284 static constexpr int digits10 = FLT_DIG;
286 static constexpr int radix = FLT_RADIX;
292 static constexpr float min() {
return -FLT_MAX; }
293 static constexpr float max() {
return FLT_MAX; }
294 static constexpr float lowest() {
return FLT_MIN; }
295 static constexpr float epsilon() {
return FLT_EPSILON; }
296 static constexpr float round_error() {
return FLT_ROUND_ERR; }
297 static constexpr float infinity() {
return FLT_INF; }
298 static constexpr float quiet_NaN() {
return FLT_QUIET_NAN; }
299 static constexpr float signaling_NaN() {
return FLT_SIGNALING_NAN; }
300 static constexpr float denorm_min() {
return FLT_DENORM_MIN; }
304template<>
struct numeric_limits<double>
309 static constexpr bool is_exact =
false;
313 static constexpr bool has_denorm = DBL_HAS_DENORM;
315 static constexpr bool is_iec559 = DBL_IS_IEC559;
319 static constexpr bool traps = DBL_TRAPS;
321 static constexpr int digits = DBL_MANT_DIG;
322 static constexpr int digits10 = DBL_DIG;
324 static constexpr int radix = DBL_RADIX;
330 static constexpr double min() {
return -DBL_MAX; }
331 static constexpr double max() {
return DBL_MAX; }
332 static constexpr double lowest() {
return DBL_MIN; }
333 static constexpr double epsilon() {
return DBL_EPSILON; }
334 static constexpr double round_error() {
return DBL_ROUND_ERR; }
335 static constexpr double infinity() {
return DBL_INF; }
336 static constexpr double quiet_NaN() {
return DBL_QUIET_NAN; }
337 static constexpr double signaling_NaN() {
return DBL_SIGNALING_NAN; }
338 static constexpr double denorm_min() {
return DBL_DENORM_MIN; }
342template<>
struct numeric_limits<char>
345 static constexpr bool is_signed = CHAR_IS_SIGNED;
347 static constexpr bool is_exact =
true;
357 static constexpr bool traps =
true;
359 static constexpr int digits = CHAR_RADIX_DIG;
360 static constexpr int digits10 = CHAR_DIG;
362 static constexpr int radix = CHAR_RADIX;
368 static constexpr char min() {
return static_cast<char>(CHAR_MIN); }
369 static constexpr char max() {
return CHAR_MAX; }
370 static constexpr char lowest() {
return 1; }
371 static constexpr char epsilon() {
return 1; }
373 static constexpr char infinity() {
return 0; }
374 static constexpr char quiet_NaN() {
return 0; }
376 static constexpr char denorm_min() {
return 0; }
380template<>
struct numeric_limits<signed char>
385 static constexpr bool is_exact =
true;
395 static constexpr bool traps =
true;
397 static constexpr int digits = SCHAR_RADIX_DIG;
398 static constexpr int digits10 = SCHAR_DIG;
400 static constexpr int radix = SCHAR_RADIX;
406 static constexpr signed char min() {
return static_cast<signed char>(SCHAR_MIN); }
407 static constexpr signed char max() {
return SCHAR_MAX; }
408 static constexpr signed char lowest() {
return 1; }
409 static constexpr signed char epsilon() {
return 1; }
410 static constexpr signed char round_error() {
return 0; }
411 static constexpr signed char infinity() {
return 0; }
412 static constexpr signed char quiet_NaN() {
return 0; }
414 static constexpr signed char denorm_min() {
return 0; }
418template<>
struct numeric_limits<unsigned char>
423 static constexpr bool is_exact =
true;
433 static constexpr bool traps =
true;
435 static constexpr int digits = UCHAR_RADIX_DIG;
436 static constexpr int digits10 = UCHAR_DIG;
438 static constexpr int radix = UCHAR_RADIX;
444 static constexpr unsigned char min() {
return UCHAR_MIN; }
445 static constexpr unsigned char max() {
return UCHAR_MAX; }
446 static constexpr unsigned char lowest() {
return 1; }
447 static constexpr unsigned char epsilon() {
return 1; }
448 static constexpr unsigned char round_error() {
return 0; }
449 static constexpr unsigned char infinity() {
return 0; }
450 static constexpr unsigned char quiet_NaN() {
return 0; }
452 static constexpr unsigned char denorm_min() {
return 0; }
456template<>
struct numeric_limits<short>
461 static constexpr bool is_exact =
true;
471 static constexpr bool traps =
true;
473 static constexpr int digits = SHORT_RADIX_DIG;
474 static constexpr int digits10 = SHORT_DIG;
476 static constexpr int radix = SHORT_RADIX;
482 static constexpr short min() {
return static_cast<short>(SHORT_MIN); }
483 static constexpr short max() {
return SHORT_MAX; }
484 static constexpr short lowest() {
return 1; }
485 static constexpr short epsilon() {
return 1; }
487 static constexpr short infinity() {
return 0; }
488 static constexpr short quiet_NaN() {
return 0; }
490 static constexpr short denorm_min() {
return 0; }
494template<>
struct numeric_limits<unsigned short>
499 static constexpr bool is_exact =
true;
509 static constexpr bool traps =
true;
511 static constexpr int digits = USHORT_RADIX_DIG;
512 static constexpr int digits10 = USHORT_DIG;
514 static constexpr int radix = USHORT_RADIX;
520 static constexpr unsigned short min() {
return USHORT_MIN; }
521 static constexpr unsigned short max() {
return USHORT_MAX; }
522 static constexpr unsigned short lowest() {
return 1; }
523 static constexpr unsigned short epsilon() {
return 1; }
524 static constexpr unsigned short round_error() {
return 0; }
525 static constexpr unsigned short infinity() {
return 0; }
526 static constexpr unsigned short quiet_NaN() {
return 0; }
527 static constexpr unsigned short signaling_NaN() {
return 0; }
528 static constexpr unsigned short denorm_min() {
return 0; }
532template<>
struct numeric_limits<int>
537 static constexpr bool is_exact =
true;
547 static constexpr bool traps =
true;
549 static constexpr int digits = INT_RADIX_DIG;
550 static constexpr int digits10 = INT_DIG;
552 static constexpr int radix = INT_RADIX;
558 static constexpr int min() {
return INT_MIN; }
559 static constexpr int max() {
return INT_MAX; }
560 static constexpr int lowest() {
return 1; }
561 static constexpr int epsilon() {
return 1; }
563 static constexpr int infinity() {
return 0; }
564 static constexpr int quiet_NaN() {
return 0; }
566 static constexpr int denorm_min() {
return 0; }
570template<>
struct numeric_limits<unsigned int>
575 static constexpr bool is_exact =
true;
585 static constexpr bool traps =
true;
587 static constexpr int digits = UINT_RADIX_DIG;
588 static constexpr int digits10 = UINT_DIG;
590 static constexpr int radix = UINT_RADIX;
596 static constexpr unsigned int min() {
return UINT_MIN; }
597 static constexpr unsigned int max() {
return UINT_MAX; }
598 static constexpr unsigned int lowest() {
return 1; }
599 static constexpr unsigned int epsilon() {
return 1; }
600 static constexpr unsigned int round_error() {
return 0; }
601 static constexpr unsigned int infinity() {
return 0; }
602 static constexpr unsigned int quiet_NaN() {
return 0; }
604 static constexpr unsigned int denorm_min() {
return 0; }
608template<>
struct numeric_limits<long int>
613 static constexpr bool is_exact =
true;
623 static constexpr bool traps =
true;
625 static constexpr int digits = LONG_RADIX_DIG;
626 static constexpr int digits10 = LONG_DIG;
628 static constexpr int radix = LONG_RADIX;
634 static constexpr long int min() {
return LONG_MIN; }
635 static constexpr long int max() {
return LONG_MAX; }
636 static constexpr long int lowest() {
return 1; }
637 static constexpr long int epsilon() {
return 1; }
638 static constexpr long int round_error() {
return 0; }
639 static constexpr long int infinity() {
return 0; }
640 static constexpr long int quiet_NaN() {
return 0; }
642 static constexpr long int denorm_min() {
return 0; }
646template<>
struct numeric_limits<unsigned long int>
651 static constexpr bool is_exact =
true;
661 static constexpr bool traps =
true;
663 static constexpr int digits = ULONG_RADIX_DIG;
664 static constexpr int digits10 = ULONG_DIG;
666 static constexpr int radix = ULONG_RADIX;
672 static constexpr unsigned long min() {
return ULONG_MIN; }
673 static constexpr unsigned long max() {
return ULONG_MAX; }
674 static constexpr unsigned long lowest() {
return 1; }
675 static constexpr unsigned long epsilon() {
return 1; }
676 static constexpr unsigned long round_error() {
return 0; }
677 static constexpr unsigned long infinity() {
return 0; }
678 static constexpr unsigned long quiet_NaN() {
return 0; }
680 static constexpr unsigned long denorm_min() {
return 0; }
684template<>
struct numeric_limits<long long>
689 static constexpr bool is_exact =
true;
699 static constexpr bool traps =
true;
701 static constexpr int digits = LLONG_RADIX_DIG;
702 static constexpr int digits10 = LLONG_DIG;
704 static constexpr int radix = LLONG_RADIX;
710 static constexpr long long min() {
return LLONG_MIN; }
711 static constexpr long long max() {
return LLONG_MAX; }
712 static constexpr long long lowest() {
return 1; }
713 static constexpr long long epsilon() {
return 1; }
714 static constexpr long long round_error() {
return 0; }
715 static constexpr long long infinity() {
return 0; }
716 static constexpr long long quiet_NaN() {
return 0; }
718 static constexpr long long denorm_min() {
return 0; }
722template<>
struct numeric_limits<unsigned long long>
727 static constexpr bool is_exact =
true;
737 static constexpr bool traps =
true;
739 static constexpr int digits = ULLONG_RADIX_DIG;
740 static constexpr int digits10 = ULLONG_DIG;
742 static constexpr int radix = ULLONG_RADIX;
748 static constexpr unsigned long long min() {
return ULLONG_MIN; }
749 static constexpr unsigned long long max() {
return ULLONG_MAX; }
750 static constexpr unsigned long long lowest() {
return 1; }
751 static constexpr unsigned long long epsilon() {
return 1; }
752 static constexpr unsigned long long round_error() {
return 0; }
753 static constexpr unsigned long long infinity() {
return 0; }
754 static constexpr unsigned long long quiet_NaN() {
return 0; }
755 static constexpr unsigned long long signaling_NaN() {
return 0; }
756 static constexpr unsigned long long denorm_min() {
return 0; }
metaprogramming floating point type info
metaprogramming integer type info
float_round_style
enum for determining rounding styles
Definition limits.h:212
Check if T is of a signed integral.
Definition type_traits.h:989
Helper for getting traits of a numeric type.
Definition limits.h:224
static constexpr bool is_modulo
Check if TypeT can handle modulo arithmetic.
Definition limits.h:236
static constexpr bool is_signed
Check if TypeT is signed.
Definition limits.h:226
static constexpr int max_exponent10
Get the maximum number of decimal digits that represent the exponent of TypeT.
Definition limits.h:247
static constexpr bool has_quiet_nan
Check if TypeT can hold a non-signaling nan.
Definition limits.h:230
static constexpr TypeT quiet_NaN()
Returns a value of TypeT holding a quiet NaN.
Definition limits.h:258
static constexpr bool traps
Check if TypeT can cause operations to trap.
Definition limits.h:238
static constexpr int max_digits10
Get the maximum number of decimal digits TypeT represents.
Definition limits.h:243
static constexpr TypeT epsilon()
Returns the difference between 1.0 and the next representable value.
Definition limits.h:255
static constexpr bool has_infinity
Check if TypeT can hold a value representing infinity.
Definition limits.h:229
static constexpr bool is_bounded
Check if TypeT represents a finite set of values.
Definition limits.h:235
static constexpr int max_exponent
Get the maximum number of radix digits that represent the exponent of TypeT.
Definition limits.h:246
static constexpr bool is_iec559
Check if a TypeT representing a float is IEC 559 or IEEE 754.
Definition limits.h:234
static constexpr int min_exponent10
Get the minimum number of decimal digits that represent the exponent of TypeT.
Definition limits.h:245
static constexpr float_round_style rounding_style
The rounding style of TypeT.
Definition limits.h:249
static constexpr TypeT infinity()
Returns a value of TypeT holding a positive infinity.
Definition limits.h:257
static constexpr bool has_denorm
Check if TypeT denormalizes.
Definition limits.h:232
static constexpr TypeT denorm_min()
Returns a value of TypeT holding the smallest positive subnormal.
Definition limits.h:260
static constexpr bool is_specialized
Check if the template is specialized for TypeT.
Definition limits.h:225
static constexpr TypeT signaling_NaN()
Returns a value of TypeT holding a signaling NaN.
Definition limits.h:259
static constexpr TypeT lowest()
Returns the smallest positive value of TypeT.
Definition limits.h:254
static constexpr TypeT max()
Returns the maximum finite value of TypeT.
Definition limits.h:253
static constexpr bool is_exact
Check if TypeT is exact in its precision.
Definition limits.h:228
static constexpr bool tinyness_before
Check if TypeT checks for tinyness before rounding.
Definition limits.h:237
static constexpr TypeT round_error()
Returns the max rounding error of TypeT.
Definition limits.h:256
static constexpr int digits
Get the number of radix digits TypeT represents.
Definition limits.h:241
static constexpr int digits10
Get the number of decimal digits TypeT represents.
Definition limits.h:242
static constexpr bool has_denorm_loss
Check if TypeT has precision loss when denormalized.
Definition limits.h:233
static constexpr bool is_integer
Check if TypeT is of an integral type.
Definition limits.h:227
static constexpr int radix
Get the base representation of the type.
Definition limits.h:240
static constexpr int min_exponent
Get the minimum number of radix digits that represent the exponent of TypeT.
Definition limits.h:244
static constexpr TypeT min()
Returns the minimum finite value of TypeT.
Definition limits.h:252
static constexpr bool has_signaling_nan
Check if TypeT can hold a signaling nan.
Definition limits.h:231