31 #ifndef ETL_LIMITS_INCLUDED
32 #define ETL_LIMITS_INCLUDED
39 #if ETL_NOT_USING_STL && defined(ETL_COMPILER_ARM5) && !defined(__USE_C99_MATH)
41 #define __USE_C99_MATH
49 #if defined(ETL_COMPILER_MICROSOFT)
51 #pragma warning(disable : 26812)
55 #define ETL_LOG10_OF_2(x) (((x) * 301) / 1000)
57 #if defined(ETL_NO_HUGE_VAL_SUPPORT)
59 #define HUGE_VAL (1.0e999999999)
63 #define HUGE_VALF (1.0e999999999F)
67 #define HUGE_VALL (1.0e999999999L)
71 #if defined(ETL_NO_CPP_NAN_SUPPORT)
73 #define ETL_NAN (double)NAN
74 #define ETL_NANF (float)NAN
75 #define ETL_NANL (long double)NAN
76 #define ETL_HAS_NAN true
78 #define ETL_NAN (double)0.0
79 #define ETL_NANF (float)0.0
80 #define ETL_NANL (long double)0.0
81 #define ETL_HAS_NAN false
84 #define ETL_NAN nan("")
85 #define ETL_NANF nanf("")
86 #define ETL_NANL nanl("")
87 #define ETL_HAS_NAN true
90 #if !defined(LDBL_MIN) && defined(DBL_MIN)
93 #define LDBL_MIN DBL_MIN
94 #define LDBL_MAX DBL_MAX
95 #define LDBL_EPSILON DBL_EPSILON
96 #define HUGE_VALL HUGE_VAL
97 #define LDBL_MANT_DIG DBL_MANT_DIG
98 #define LDBL_DIG DBL_DIG
99 #define LDBL_MIN_EXP DBL_MIN_EXP
100 #define LDBL_MIN_10_EXP DBL_MIN_10_EXP
101 #define LDBL_MAX_EXP DBL_MAX_EXP
102 #define LDBL_MAX_10_EXP DBL_MAX_10_EXP
107 enum float_round_style
109 round_indeterminate = -1,
110 round_toward_zero = 0,
111 round_to_nearest = 1,
112 round_toward_infinity = 2,
113 round_toward_neg_infinity = 3,
116 enum float_denorm_style
118 denorm_indeterminate = -1,
124 class etl_integral_limits
128 static ETL_CONSTANT
bool is_specialized =
true;
129 static ETL_CONSTANT
bool is_integer =
true;
130 static ETL_CONSTANT
bool is_exact =
true;
131 static ETL_CONSTANT
int max_digits10 = 0;
132 static ETL_CONSTANT
int radix = 2;
133 static ETL_CONSTANT
int min_exponent = 0;
134 static ETL_CONSTANT
int min_exponent10 = 0;
135 static ETL_CONSTANT
int max_exponent = 0;
136 static ETL_CONSTANT
int max_exponent10 = 0;
137 static ETL_CONSTANT
bool has_infinity =
false;
138 static ETL_CONSTANT
bool has_quiet_NaN =
false;
139 static ETL_CONSTANT
bool has_signaling_NaN =
false;
140 static ETL_CONSTANT
bool has_denorm_loss =
false;
141 static ETL_CONSTANT
bool is_iec559 =
false;
142 static ETL_CONSTANT
bool is_bounded =
true;
143 static ETL_CONSTANT
bool traps =
false;
144 static ETL_CONSTANT
bool tinyness_before =
false;
145 static ETL_CONSTANT float_denorm_style has_denorm = denorm_absent;
146 static ETL_CONSTANT float_round_style round_style = round_toward_zero;
149 class etl_floating_point_limits
153 static ETL_CONSTANT
bool is_specialized =
true;
154 static ETL_CONSTANT
bool is_signed =
true;
155 static ETL_CONSTANT
bool is_integer =
false;
156 static ETL_CONSTANT
bool is_exact =
false;
157 static ETL_CONSTANT
int radix = 2;
158 static ETL_CONSTANT
bool has_infinity =
true;
159 static ETL_CONSTANT
bool has_quiet_NaN = ETL_HAS_NAN;
160 static ETL_CONSTANT
bool has_signaling_NaN = ETL_HAS_NAN;
161 static ETL_CONSTANT
bool has_denorm_loss =
false;
162 static ETL_CONSTANT
bool is_iec559 =
false;
163 static ETL_CONSTANT
bool is_bounded =
true;
164 static ETL_CONSTANT
bool is_modulo =
false;
165 static ETL_CONSTANT
bool traps =
false;
166 static ETL_CONSTANT
bool tinyness_before =
false;
167 static ETL_CONSTANT float_denorm_style has_denorm = denorm_indeterminate;
168 static ETL_CONSTANT float_round_style round_style = round_indeterminate;
170 static float round_error() {
return float(0.5); }
175 template <
typename T>
176 class numeric_limits;
178 template <
typename T>
179 class numeric_limits<const T> :
public numeric_limits<T> { };
181 template <
typename T>
182 class numeric_limits<volatile T> :
public numeric_limits<T> { };
184 template <
typename T>
185 class numeric_limits<const volatile T> :
public numeric_limits<T> { };
190 class numeric_limits<bool> :
public etl_integral_limits
194 static ETL_CONSTANT
int digits = 1;
195 static ETL_CONSTANT
int digits10 = 0;
196 static ETL_CONSTANT
bool is_signed =
false;
197 static ETL_CONSTANT
bool is_modulo =
false;
199 static bool min() {
return false; }
200 static bool max() {
return true; }
201 static bool lowest() {
return false; }
202 static bool epsilon() {
return false; }
203 static bool round_error() {
return false; }
204 static bool denorm_min() {
return false; }
205 static bool infinity() {
return false; }
206 static bool quiet_NaN() {
return false; }
207 static bool signaling_NaN() {
return false; }
213 class numeric_limits<char> :
public etl_integral_limits
218 static ETL_CONSTANT
int digits10 = ETL_LOG10_OF_2(digits);
220 static ETL_CONSTANT
bool is_modulo =
false;
222 static char min() {
return char(CHAR_MIN); }
223 static char max() {
return char(CHAR_MAX); }
224 static char lowest() {
return char(CHAR_MIN); }
225 static char epsilon() {
return 0; }
226 static char round_error() {
return 0; }
227 static char denorm_min() {
return 0; }
228 static char infinity() {
return 0; }
229 static char quiet_NaN() {
return 0; }
230 static char signaling_NaN() {
return 0; }
236 class numeric_limits<unsigned char> :
public etl_integral_limits
241 static ETL_CONSTANT
int digits10 = ETL_LOG10_OF_2(digits);
242 static ETL_CONSTANT
bool is_signed =
false;
243 static ETL_CONSTANT
bool is_modulo =
true;
245 static unsigned char min() {
return 0U; }
246 static unsigned char max() {
return UCHAR_MAX; }
247 static unsigned char lowest() {
return 0U; }
248 static unsigned char epsilon() {
return 0U; }
249 static unsigned char round_error() {
return 0U; }
250 static unsigned char denorm_min() {
return 0U; }
251 static unsigned char infinity() {
return 0U; }
252 static unsigned char quiet_NaN() {
return 0U; }
253 static unsigned char signaling_NaN() {
return 0U; }
259 class numeric_limits<signed char> :
public etl_integral_limits
264 static ETL_CONSTANT
int digits10 = ETL_LOG10_OF_2(digits);
265 static ETL_CONSTANT
bool is_signed =
true;
266 static ETL_CONSTANT
bool is_modulo =
false;
268 static signed char min() {
return SCHAR_MIN; }
269 static signed char max() {
return SCHAR_MAX; }
270 static signed char lowest() {
return SCHAR_MIN; }
271 static signed char epsilon() {
return 0; }
272 static signed char round_error() {
return 0; }
273 static signed char denorm_min() {
return 0; }
274 static signed char infinity() {
return 0; }
275 static signed char quiet_NaN() {
return 0; }
276 static signed char signaling_NaN() {
return 0; }
279 #if (ETL_NO_LARGE_CHAR_SUPPORT == false)
283 class numeric_limits<char16_t> :
public etl_integral_limits
288 static ETL_CONSTANT
int digits10 = ETL_LOG10_OF_2(digits);
289 static ETL_CONSTANT
bool is_signed =
false;
290 static ETL_CONSTANT
bool is_modulo =
true;
292 static char16_t min() {
return 0U; }
293 static char16_t max() {
return UINT_LEAST16_MAX; }
294 static char16_t lowest() {
return 0U; }
295 static char16_t epsilon() {
return 0U; }
296 static char16_t round_error() {
return 0U; }
297 static char16_t denorm_min() {
return 0U; }
298 static char16_t infinity() {
return 0U; }
299 static char16_t quiet_NaN() {
return 0U; }
300 static char16_t signaling_NaN() {
return 0U; }
306 class numeric_limits<char32_t> :
public etl_integral_limits
311 static ETL_CONSTANT
int digits10 = ETL_LOG10_OF_2(digits);
312 static ETL_CONSTANT
bool is_signed =
false;
313 static ETL_CONSTANT
bool is_modulo =
true;
315 static char32_t min() {
return 0U; }
316 static char32_t max() {
return UINT_LEAST32_MAX; }
317 static char32_t lowest() {
return 0U; }
318 static char32_t epsilon() {
return 0U; }
319 static char32_t round_error() {
return 0U; }
320 static char32_t denorm_min() {
return 0U; }
321 static char32_t infinity() {
return 0U; }
322 static char32_t quiet_NaN() {
return 0U; }
323 static char32_t signaling_NaN() {
return 0U; }
331 class numeric_limits<wchar_t> :
public etl_integral_limits
336 static ETL_CONSTANT
int digits10 = ETL_LOG10_OF_2(digits);
340 static wchar_t min() {
return WCHAR_MIN; }
341 static wchar_t max() {
return WCHAR_MAX; }
342 static wchar_t lowest() {
return WCHAR_MIN; }
343 static wchar_t epsilon() {
return wchar_t(0); }
344 static wchar_t round_error() {
return wchar_t(0); }
345 static wchar_t denorm_min() {
return wchar_t(0); }
346 static wchar_t infinity() {
return wchar_t(0); }
347 static wchar_t quiet_NaN() {
return wchar_t(0); }
348 static wchar_t signaling_NaN() {
return wchar_t(0); }
354 class numeric_limits<short> :
public etl_integral_limits
359 static ETL_CONSTANT
int digits10 = ETL_LOG10_OF_2(digits);
360 static ETL_CONSTANT
bool is_signed =
true;
361 static ETL_CONSTANT
bool is_modulo =
false;
363 static short min() {
return SHRT_MIN; }
364 static short max() {
return SHRT_MAX; }
365 static short lowest() {
return SHRT_MIN; }
366 static short epsilon() {
return 0; }
367 static short round_error() {
return 0; }
368 static short denorm_min() {
return 0; }
369 static short infinity() {
return 0; }
370 static short quiet_NaN() {
return 0; }
371 static short signaling_NaN() {
return 0; }
377 class numeric_limits<unsigned short> :
public etl_integral_limits
382 static ETL_CONSTANT
int digits10 = ETL_LOG10_OF_2(digits);
383 static ETL_CONSTANT
bool is_signed =
false;
384 static ETL_CONSTANT
bool is_modulo =
true;
386 static unsigned short min() {
return 0U; }
387 static unsigned short max() {
return USHRT_MAX; }
388 static unsigned short lowest() {
return 0U; }
389 static unsigned short epsilon() {
return 0U; }
390 static unsigned short round_error() {
return 0U; }
391 static unsigned short denorm_min() {
return 0U; }
392 static unsigned short infinity() {
return 0U; }
393 static unsigned short quiet_NaN() {
return 0U; }
394 static unsigned short signaling_NaN() {
return 0U; }
401 class numeric_limits<int> :
public etl_integral_limits
406 static ETL_CONSTANT
int digits10 = ETL_LOG10_OF_2(digits);
407 static ETL_CONSTANT
bool is_signed =
true;
408 static ETL_CONSTANT
bool is_modulo =
false;
410 static int min() {
return INT_MIN; }
411 static int max() {
return INT_MAX; }
412 static int lowest() {
return INT_MIN; }
413 static int epsilon() {
return 0; }
414 static int round_error() {
return 0; }
415 static int denorm_min() {
return 0; }
416 static int infinity() {
return 0; }
417 static int quiet_NaN() {
return 0; }
418 static int signaling_NaN() {
return 0; }
424 class numeric_limits<unsigned int> :
public etl_integral_limits
429 static ETL_CONSTANT
int digits10 = ETL_LOG10_OF_2(digits);
430 static ETL_CONSTANT
bool is_signed =
false;
431 static ETL_CONSTANT
bool is_modulo =
true;
433 static unsigned int min() {
return 0U; }
434 static unsigned int max() {
return UINT_MAX; }
435 static unsigned int lowest() {
return 0U; }
436 static unsigned int epsilon() {
return 0U; }
437 static unsigned int round_error() {
return 0U; }
438 static unsigned int denorm_min() {
return 0U; }
439 static unsigned int infinity() {
return 0U; }
440 static unsigned int quiet_NaN() {
return 0U; }
441 static unsigned int signaling_NaN() {
return 0U; }
447 class numeric_limits<long> :
public etl_integral_limits
452 static ETL_CONSTANT
int digits10 = ETL_LOG10_OF_2(digits);
453 static ETL_CONSTANT
bool is_signed =
true;
454 static ETL_CONSTANT
bool is_modulo =
false;
456 static long min() {
return LONG_MIN; }
457 static long max() {
return LONG_MAX; }
458 static long lowest() {
return LONG_MIN; }
459 static long epsilon() {
return 0; }
460 static long round_error() {
return 0; }
461 static long denorm_min() {
return 0; }
462 static long infinity() {
return 0; }
463 static long quiet_NaN() {
return 0; }
464 static long signaling_NaN() {
return 0; }
470 class numeric_limits<unsigned long> :
public etl_integral_limits
475 static ETL_CONSTANT
int digits10 = ETL_LOG10_OF_2(digits);
476 static ETL_CONSTANT
bool is_signed =
false;
477 static ETL_CONSTANT
bool is_modulo =
true;
479 static unsigned long min() {
return 0U; }
480 static unsigned long max() {
return ULONG_MAX; }
481 static unsigned long lowest() {
return 0U; }
482 static unsigned long epsilon() {
return 0U; }
483 static unsigned long round_error() {
return 0U; }
484 static unsigned long denorm_min() {
return 0U; }
485 static unsigned long infinity() {
return 0U; }
486 static unsigned long quiet_NaN() {
return 0U; }
487 static unsigned long signaling_NaN() {
return 0U; }
493 class numeric_limits<long long> :
public etl_integral_limits
498 static ETL_CONSTANT
int digits10 = ETL_LOG10_OF_2(digits);
499 static ETL_CONSTANT
bool is_signed =
true;
500 static ETL_CONSTANT
bool is_modulo =
false;
502 static long long min() {
return LLONG_MIN; }
503 static long long max() {
return LLONG_MAX; }
504 static long long lowest() {
return LLONG_MIN; }
505 static long long epsilon() {
return 0; }
506 static long long round_error() {
return 0; }
507 static long long denorm_min() {
return 0; }
508 static long long infinity() {
return 0; }
509 static long long quiet_NaN() {
return 0; }
510 static long long signaling_NaN() {
return 0; }
516 class numeric_limits<unsigned long long> :
public etl_integral_limits
521 static ETL_CONSTANT
int digits10 = ETL_LOG10_OF_2(digits);
522 static ETL_CONSTANT
bool is_signed =
false;
523 static ETL_CONSTANT
bool is_modulo =
true;
525 static unsigned long long min() {
return 0U; }
526 static unsigned long long max() {
return ULLONG_MAX; }
527 static unsigned long long lowest() {
return 0U; }
528 static unsigned long long epsilon() {
return 0U; }
529 static unsigned long long round_error() {
return 0U; }
530 static unsigned long long denorm_min() {
return 0U; }
531 static unsigned long long infinity() {
return 0U; }
532 static unsigned long long quiet_NaN() {
return 0U; }
533 static unsigned long long signaling_NaN() {
return 0U; }
539 class numeric_limits<float> :
public etl_floating_point_limits
543 static float min() {
return FLT_MIN; }
544 static float max() {
return FLT_MAX; }
545 static float lowest() {
return -FLT_MAX; }
546 static float epsilon() {
return FLT_EPSILON; }
547 static float denorm_min() {
return FLT_MIN; }
548 static float infinity() {
return HUGE_VALF; }
549 static float quiet_NaN() {
return ETL_NANF; }
550 static float signaling_NaN() {
return ETL_NANF; }
552 static ETL_CONSTANT
int digits = FLT_MANT_DIG;
553 static ETL_CONSTANT
int digits10 = FLT_DIG;
554 static ETL_CONSTANT
int max_digits10 = ETL_LOG10_OF_2(FLT_MANT_DIG) + 2;
556 static ETL_CONSTANT
int min_exponent = FLT_MIN_EXP;
557 static ETL_CONSTANT
int min_exponent10 = FLT_MIN_10_EXP;
558 static ETL_CONSTANT
int max_exponent = FLT_MAX_EXP;
559 static ETL_CONSTANT
int max_exponent10 = FLT_MAX_10_EXP;
565 class numeric_limits<double> :
public etl_floating_point_limits
569 static double min() {
return DBL_MIN; }
570 static double max() {
return DBL_MAX; }
571 static double lowest() {
return -DBL_MAX; }
572 static double epsilon() {
return DBL_EPSILON; }
573 static double denorm_min() {
return DBL_MIN; }
574 static double infinity() {
return HUGE_VAL; }
575 static double quiet_NaN() {
return ETL_NAN; }
576 static double signaling_NaN() {
return ETL_NAN; }
578 static ETL_CONSTANT
int digits = DBL_MANT_DIG;
579 static ETL_CONSTANT
int digits10 = DBL_DIG;
580 static ETL_CONSTANT
int max_digits10 = ETL_LOG10_OF_2(DBL_MANT_DIG) + 2;
582 static ETL_CONSTANT
int min_exponent = DBL_MIN_EXP;
583 static ETL_CONSTANT
int min_exponent10 = DBL_MIN_10_EXP;
584 static ETL_CONSTANT
int max_exponent = DBL_MAX_EXP;
585 static ETL_CONSTANT
int max_exponent10 = DBL_MAX_10_EXP;
591 class numeric_limits<long double> :
public etl_floating_point_limits
595 static long double min() {
return LDBL_MIN; }
596 static long double max() {
return LDBL_MAX; }
597 static long double lowest() {
return -LDBL_MAX; }
598 static long double epsilon() {
return LDBL_EPSILON; }
599 static long double denorm_min() {
return LDBL_MIN; }
600 static long double infinity() {
return HUGE_VALL; }
601 static long double quiet_NaN() {
return ETL_NANL; }
602 static long double signaling_NaN() {
return ETL_NANL; }
604 static ETL_CONSTANT
int digits = LDBL_MANT_DIG;
605 static ETL_CONSTANT
int digits10 = LDBL_DIG;
606 static ETL_CONSTANT
int max_digits10 = ETL_LOG10_OF_2(LDBL_MANT_DIG) + 2;
608 static ETL_CONSTANT
int min_exponent = LDBL_MIN_EXP;
609 static ETL_CONSTANT
int min_exponent10 = LDBL_MIN_10_EXP;
610 static ETL_CONSTANT
int max_exponent = LDBL_MAX_EXP;
611 static ETL_CONSTANT
int max_exponent10 = LDBL_MAX_10_EXP;
621 enum float_round_style
623 round_indeterminate = std::round_indeterminate,
624 round_toward_zero = std::round_toward_zero,
625 round_to_nearest = std::round_to_nearest,
626 round_toward_infinity = std::round_toward_infinity,
627 round_toward_neg_infinity = std::round_toward_neg_infinity,
630 enum float_denorm_style
632 denorm_indeterminate = std::denorm_indeterminate,
633 denorm_absent = std::denorm_absent,
634 denorm_present = std::denorm_present
637 template <
typename T>
644 #if defined(ETL_COMPILER_MICROSOFT)
is_signed
Definition: type_traits_generator.h:951
is_unsigned
Definition: type_traits_generator.h:961
Definition: absolute.h:37