Embedded Template Library 1.0
Loading...
Searching...
No Matches
limits.h
Go to the documentation of this file.
1
2
3/******************************************************************************
4The MIT License(MIT)
5
6Embedded Template Library.
7https://github.com/ETLCPP/etl
8https://www.etlcpp.com
9
10Copyright(c) 2018 John Wellbelove
11
12Permission is hereby granted, free of charge, to any person obtaining a copy
13of this software and associated documentation files(the "Software"), to deal
14in the Software without restriction, including without limitation the rights
15to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16copies of the Software, and to permit persons to whom the Software is
17furnished to do so, subject to the following conditions :
18
19The above copyright notice and this permission notice shall be included in all
20copies or substantial portions of the Software.
21
22THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28SOFTWARE.
29******************************************************************************/
30
31#ifndef ETL_LIMITS_INCLUDED
32#define ETL_LIMITS_INCLUDED
33
34#include "platform.h"
35#include "integral_limits.h"
36#include "type_traits.h"
37
38#if ETL_NOT_USING_STL && defined(ETL_COMPILER_ARM5) && !defined(__USE_C99_MATH)
39 // Required for nan, nanf, nanl
40 #define __USE_C99_MATH
41#endif
42
43#include <float.h>
44#include <limits.h>
45#include <math.h>
46
47#include "private/minmax_push.h"
48
49#if defined(ETL_COMPILER_MICROSOFT)
50 #pragma warning(push)
51 #pragma warning(disable : 26812)
52#endif
53
54#if ETL_NOT_USING_STL
55 #define ETL_LOG10_OF_2(x) (((x) * 301) / 1000)
56
57 #if !defined(LDBL_MIN) && defined(DBL_MIN)
58 // Looks like we don't have these macros defined.
59 // That probably means that 'long double' is the same size as 'double'.
60 #define LDBL_MIN DBL_MIN
61 #define LDBL_MAX DBL_MAX
62 #define LDBL_EPSILON DBL_EPSILON
63 #define LDBL_MANT_DIG DBL_MANT_DIG
64 #define LDBL_DIG DBL_DIG
65 #define LDBL_MIN_EXP DBL_MIN_EXP
66 #define LDBL_MIN_10_EXP DBL_MIN_10_EXP
67 #define LDBL_MAX_EXP DBL_MAX_EXP
68 #define LDBL_MAX_10_EXP DBL_MAX_10_EXP
69 #endif
70
71 #if !defined(HUGE_VAL)
72 // Looks like we don't have these macros defined.
73 // They're compiler implementation dependent, so we'll make them the same as
74 // the max values.
75 #define HUGE_VALF FLT_MAX
76 #define HUGE_VAL DBL_MAX
77 #define HUGE_VALL LDBL_MAX
78 #endif
79
80 #if defined(ETL_NO_CPP_NAN_SUPPORT)
81 #if defined(NAN)
83 #define ETL_NANF NAN
84 #define ETL_NAN static_cast<double>(NAN)
85 #define ETL_NANL static_cast<long double>(NAN)
86 #define ETL_HAS_NAN true
88 #else
90 #define ETL_NANF HUGE_VALF
91 #define ETL_NAN HUGE_VAL
92 #define ETL_NANL HUGE_VALL
93 #define ETL_HAS_NAN false
95 #endif
96 #else
97 #define ETL_NANF nanf("")
98 #define ETL_NAN nan("")
99 #define ETL_NANL nanl("")
100 #define ETL_HAS_NAN true
101 #endif
102
103namespace etl
104{
105 enum float_round_style
106 {
107 round_indeterminate = -1,
108 round_toward_zero = 0,
109 round_to_nearest = 1,
110 round_toward_infinity = 2,
111 round_toward_neg_infinity = 3,
112 };
113
114 enum float_denorm_style
115 {
116 denorm_indeterminate = -1,
117 denorm_absent = 0,
118 denorm_present = 1
119 };
120
121 namespace private_limits
122 {
123 //*********************************
124 // Integral limits common
125 template <typename T = void>
126 class integral_limits_common
127 {
128 public:
129
130 static ETL_CONSTANT bool is_specialized = true;
131 static ETL_CONSTANT bool is_integer = true;
132 static ETL_CONSTANT bool is_exact = true;
133 static ETL_CONSTANT int max_digits10 = 0;
134 static ETL_CONSTANT int radix = 2;
135 static ETL_CONSTANT int min_exponent = 0;
136 static ETL_CONSTANT int min_exponent10 = 0;
137 static ETL_CONSTANT int max_exponent = 0;
138 static ETL_CONSTANT int max_exponent10 = 0;
139 static ETL_CONSTANT bool has_infinity = false;
140 static ETL_CONSTANT bool has_quiet_NaN = false;
141 static ETL_CONSTANT bool has_signaling_NaN = false;
142 static ETL_CONSTANT bool has_denorm_loss = false;
143 static ETL_CONSTANT bool is_iec559 = false;
144 static ETL_CONSTANT bool is_bounded = true;
145 static ETL_CONSTANT bool traps = false;
146 static ETL_CONSTANT bool tinyness_before = false;
147 static ETL_CONSTANT float_denorm_style has_denorm = denorm_absent;
148 static ETL_CONSTANT float_round_style round_style = round_toward_zero;
149 };
150
151 template <typename T>
152 ETL_CONSTANT bool integral_limits_common<T>::is_specialized;
153
154 template <typename T>
155 ETL_CONSTANT bool integral_limits_common<T>::is_integer;
156
157 template <typename T>
158 ETL_CONSTANT bool integral_limits_common<T>::is_exact;
159
160 template <typename T>
161 ETL_CONSTANT int integral_limits_common<T>::max_digits10;
162
163 template <typename T>
164 ETL_CONSTANT int integral_limits_common<T>::radix;
165
166 template <typename T>
167 ETL_CONSTANT int integral_limits_common<T>::min_exponent;
168
169 template <typename T>
170 ETL_CONSTANT int integral_limits_common<T>::min_exponent10;
171
172 template <typename T>
173 ETL_CONSTANT int integral_limits_common<T>::max_exponent;
174
175 template <typename T>
176 ETL_CONSTANT int integral_limits_common<T>::max_exponent10;
177
178 template <typename T>
179 ETL_CONSTANT bool integral_limits_common<T>::has_infinity;
180
181 template <typename T>
182 ETL_CONSTANT bool integral_limits_common<T>::has_quiet_NaN;
183
184 template <typename T>
185 ETL_CONSTANT bool integral_limits_common<T>::has_signaling_NaN;
186
187 template <typename T>
188 ETL_CONSTANT bool integral_limits_common<T>::has_denorm_loss;
189
190 template <typename T>
191 ETL_CONSTANT bool integral_limits_common<T>::is_iec559;
192
193 template <typename T>
194 ETL_CONSTANT bool integral_limits_common<T>::is_bounded;
195
196 template <typename T>
197 ETL_CONSTANT bool integral_limits_common<T>::traps;
198
199 template <typename T>
200 ETL_CONSTANT bool integral_limits_common<T>::tinyness_before;
201
202 template <typename T>
203 ETL_CONSTANT float_denorm_style integral_limits_common<T>::has_denorm;
204
205 template <typename T>
206 ETL_CONSTANT float_round_style integral_limits_common<T>::round_style;
207
208 //*********************************
209 // bool
210 template <typename T = void>
211 struct integral_limits_bool
212 {
213 static ETL_CONSTANT int digits = 1;
214 static ETL_CONSTANT int digits10 = 0;
215 static ETL_CONSTANT bool is_signed = false;
216 static ETL_CONSTANT bool is_modulo = false;
217 };
218
219 template <typename T>
220 ETL_CONSTANT int integral_limits_bool<T>::digits;
221
222 template <typename T>
223 ETL_CONSTANT int integral_limits_bool<T>::digits10;
224
225 template <typename T>
226 ETL_CONSTANT bool integral_limits_bool<T>::is_signed;
227
228 template <typename T>
229 ETL_CONSTANT bool integral_limits_bool<T>::is_modulo;
230
231 //*********************************
232 // char
233 template <typename T = void>
234 struct integral_limits_char
235 {
236 static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char)) - (etl::is_signed<char>::value ? 1 : 0);
237 static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
238 static ETL_CONSTANT bool is_signed = etl::is_signed<char>::value;
239 static ETL_CONSTANT bool is_modulo = etl::is_unsigned<char>::value;
240 };
241
242 template <typename T>
243 ETL_CONSTANT int integral_limits_char<T>::digits;
244
245 template <typename T>
246 ETL_CONSTANT int integral_limits_char<T>::digits10;
247
248 template <typename T>
249 ETL_CONSTANT bool integral_limits_char<T>::is_signed;
250
251 template <typename T>
252 ETL_CONSTANT bool integral_limits_char<T>::is_modulo;
253
254 //*********************************
255 // unsigned char
256 template <typename T = void>
257 struct integral_limits_unsigned_char
258 {
259 static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned char));
260 static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
261 static ETL_CONSTANT bool is_signed = false;
262 static ETL_CONSTANT bool is_modulo = true;
263 };
264
265 template <typename T>
266 ETL_CONSTANT int integral_limits_unsigned_char<T>::digits;
267
268 template <typename T>
269 ETL_CONSTANT int integral_limits_unsigned_char<T>::digits10;
270
271 template <typename T>
272 ETL_CONSTANT bool integral_limits_unsigned_char<T>::is_signed;
273
274 template <typename T>
275 ETL_CONSTANT bool integral_limits_unsigned_char<T>::is_modulo;
276
277 //*********************************
278 // signed char
279 template <typename T = void>
280 struct integral_limits_signed_char
281 {
282 static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char)) - 1;
283 static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
284 static ETL_CONSTANT bool is_signed = true;
285 static ETL_CONSTANT bool is_modulo = false;
286 };
287
288 template <typename T>
289 ETL_CONSTANT int integral_limits_signed_char<T>::digits;
290
291 template <typename T>
292 ETL_CONSTANT int integral_limits_signed_char<T>::digits10;
293
294 template <typename T>
295 ETL_CONSTANT bool integral_limits_signed_char<T>::is_signed;
296
297 template <typename T>
298 ETL_CONSTANT bool integral_limits_signed_char<T>::is_modulo;
299
300 #if ETL_HAS_NATIVE_CHAR8_T
301 //*********************************
302 // char8_t
303 template <typename T = void>
304 struct integral_limits_char8_t
305 {
306 static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char8_t)) - (etl::is_signed<char8_t>::value ? 1 : 0);
307 static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
308 static ETL_CONSTANT bool is_signed = etl::is_signed<char8_t>::value;
309 static ETL_CONSTANT bool is_modulo = false;
310 };
311
312 template <typename T>
313 ETL_CONSTANT int integral_limits_char8_t<T>::digits;
314
315 template <typename T>
316 ETL_CONSTANT int integral_limits_char8_t<T>::digits10;
317
318 template <typename T>
319 ETL_CONSTANT bool integral_limits_char8_t<T>::is_signed;
320
321 template <typename T>
322 ETL_CONSTANT bool integral_limits_char8_t<T>::is_modulo;
323 #endif
324
325 #if ETL_HAS_NATIVE_CHAR16_T
326 //*********************************
327 // char16_t
328 template <typename T = void>
329 struct integral_limits_char16_t
330 {
331 static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char16_t));
332 static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
333 static ETL_CONSTANT bool is_signed = false;
334 static ETL_CONSTANT bool is_modulo = true;
335 };
336
337 template <typename T>
338 ETL_CONSTANT int integral_limits_char16_t<T>::digits;
339
340 template <typename T>
341 ETL_CONSTANT int integral_limits_char16_t<T>::digits10;
342
343 template <typename T>
344 ETL_CONSTANT bool integral_limits_char16_t<T>::is_signed;
345
346 template <typename T>
347 ETL_CONSTANT bool integral_limits_char16_t<T>::is_modulo;
348 #endif
349
350 #if ETL_HAS_NATIVE_CHAR32_T
351 //*********************************
352 // char32_t
353 template <typename T = void>
354 struct integral_limits_char32_t
355 {
356 static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char32_t));
357 static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
358 static ETL_CONSTANT bool is_signed = false;
359 static ETL_CONSTANT bool is_modulo = true;
360 };
361
362 template <typename T>
363 ETL_CONSTANT int integral_limits_char32_t<T>::digits;
364
365 template <typename T>
366 ETL_CONSTANT int integral_limits_char32_t<T>::digits10;
367
368 template <typename T>
369 ETL_CONSTANT bool integral_limits_char32_t<T>::is_signed;
370
371 template <typename T>
372 ETL_CONSTANT bool integral_limits_char32_t<T>::is_modulo;
373 #endif
374
375 //*********************************
376 // wchar_t
377 template <typename T = void>
378 struct integral_limits_wchar_t
379 {
380 static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(wchar_t)) - (etl::is_signed<wchar_t>::value ? 1 : 0);
381 static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
382 static ETL_CONSTANT bool is_signed = etl::is_signed<wchar_t>::value;
383 static ETL_CONSTANT bool is_modulo = etl::is_unsigned<wchar_t>::value;
384 };
385
386 template <typename T>
387 ETL_CONSTANT int integral_limits_wchar_t<T>::digits;
388
389 template <typename T>
390 ETL_CONSTANT int integral_limits_wchar_t<T>::digits10;
391
392 template <typename T>
393 ETL_CONSTANT bool integral_limits_wchar_t<T>::is_signed;
394
395 template <typename T>
396 ETL_CONSTANT bool integral_limits_wchar_t<T>::is_modulo;
397
398 //*********************************
399 // short
400 template <typename T = void>
401 struct integral_limits_short
402 {
403 static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(short)) - 1;
404 static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
405 static ETL_CONSTANT bool is_signed = true;
406 static ETL_CONSTANT bool is_modulo = false;
407 };
408
409 template <typename T>
410 ETL_CONSTANT int integral_limits_short<T>::digits;
411
412 template <typename T>
413 ETL_CONSTANT int integral_limits_short<T>::digits10;
414
415 template <typename T>
416 ETL_CONSTANT bool integral_limits_short<T>::is_signed;
417
418 template <typename T>
419 ETL_CONSTANT bool integral_limits_short<T>::is_modulo;
420
421 //*********************************
422 // unsigned short
423 template <typename T = void>
424 struct integral_limits_unsigned_short
425 {
426 static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned short));
427 static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
428 static ETL_CONSTANT bool is_signed = false;
429 static ETL_CONSTANT bool is_modulo = true;
430 };
431
432 template <typename T>
433 ETL_CONSTANT int integral_limits_unsigned_short<T>::digits;
434
435 template <typename T>
436 ETL_CONSTANT int integral_limits_unsigned_short<T>::digits10;
437
438 template <typename T>
439 ETL_CONSTANT bool integral_limits_unsigned_short<T>::is_signed;
440
441 template <typename T>
442 ETL_CONSTANT bool integral_limits_unsigned_short<T>::is_modulo;
443
444 //*********************************
445 // int
446 template <typename T = void>
447 struct integral_limits_int
448 {
449 static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(int)) - 1;
450 static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
451 static ETL_CONSTANT bool is_signed = true;
452 static ETL_CONSTANT bool is_modulo = false;
453 };
454
455 template <typename T>
456 ETL_CONSTANT int integral_limits_int<T>::digits;
457
458 template <typename T>
459 ETL_CONSTANT int integral_limits_int<T>::digits10;
460
461 template <typename T>
462 ETL_CONSTANT bool integral_limits_int<T>::is_signed;
463
464 template <typename T>
465 ETL_CONSTANT bool integral_limits_int<T>::is_modulo;
466
467 //*********************************
468 // unsigned int
469 template <typename T = void>
470 struct integral_limits_unsigned_int
471 {
472 static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned int));
473 static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
474 static ETL_CONSTANT bool is_signed = false;
475 static ETL_CONSTANT bool is_modulo = true;
476 };
477
478 template <typename T>
479 ETL_CONSTANT int integral_limits_unsigned_int<T>::digits;
480
481 template <typename T>
482 ETL_CONSTANT int integral_limits_unsigned_int<T>::digits10;
483
484 template <typename T>
485 ETL_CONSTANT bool integral_limits_unsigned_int<T>::is_signed;
486
487 template <typename T>
488 ETL_CONSTANT bool integral_limits_unsigned_int<T>::is_modulo;
489
490 //*********************************
491 // long
492 template <typename T = void>
493 struct integral_limits_long
494 {
495 static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(long)) - 1;
496 static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
497 static ETL_CONSTANT bool is_signed = true;
498 static ETL_CONSTANT bool is_modulo = false;
499 };
500
501 template <typename T>
502 ETL_CONSTANT int integral_limits_long<T>::digits;
503
504 template <typename T>
505 ETL_CONSTANT int integral_limits_long<T>::digits10;
506
507 template <typename T>
508 ETL_CONSTANT bool integral_limits_long<T>::is_signed;
509
510 template <typename T>
511 ETL_CONSTANT bool integral_limits_long<T>::is_modulo;
512
513 //*********************************
514 // unsigned long
515 template <typename T = void>
516 struct integral_limits_unsigned_long
517 {
518 static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned long));
519 static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
520 static ETL_CONSTANT bool is_signed = false;
521 static ETL_CONSTANT bool is_modulo = true;
522 };
523
524 template <typename T>
525 ETL_CONSTANT int integral_limits_unsigned_long<T>::digits;
526
527 template <typename T>
528 ETL_CONSTANT int integral_limits_unsigned_long<T>::digits10;
529
530 template <typename T>
531 ETL_CONSTANT bool integral_limits_unsigned_long<T>::is_signed;
532
533 template <typename T>
534 ETL_CONSTANT bool integral_limits_unsigned_long<T>::is_modulo;
535
536 //*********************************
537 // long long
538 template <typename T = void>
539 struct integral_limits_long_long
540 {
541 static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(long long)) - 1;
542 static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
543 static ETL_CONSTANT bool is_signed = true;
544 static ETL_CONSTANT bool is_modulo = false;
545 };
546
547 template <typename T>
548 ETL_CONSTANT int integral_limits_long_long<T>::digits;
549
550 template <typename T>
551 ETL_CONSTANT int integral_limits_long_long<T>::digits10;
552
553 template <typename T>
554 ETL_CONSTANT bool integral_limits_long_long<T>::is_signed;
555
556 template <typename T>
557 ETL_CONSTANT bool integral_limits_long_long<T>::is_modulo;
558
559 //*********************************
560 // unsigned long long
561 template <typename T = void>
562 struct integral_limits_unsigned_long_long
563 {
564 static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned long long));
565 static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
566 static ETL_CONSTANT bool is_signed = false;
567 static ETL_CONSTANT bool is_modulo = true;
568 };
569
570 template <typename T>
571 ETL_CONSTANT int integral_limits_unsigned_long_long<T>::digits;
572
573 template <typename T>
574 ETL_CONSTANT int integral_limits_unsigned_long_long<T>::digits10;
575
576 template <typename T>
577 ETL_CONSTANT bool integral_limits_unsigned_long_long<T>::is_signed;
578
579 template <typename T>
580 ETL_CONSTANT bool integral_limits_unsigned_long_long<T>::is_modulo;
581
582 //*********************************
583 // Floating point limits common
584 template <typename T = void>
585 class floating_point_limits_common
586 {
587 public:
588
589 static ETL_CONSTANT bool is_specialized = true;
590 static ETL_CONSTANT bool is_signed = true;
591 static ETL_CONSTANT bool is_integer = false;
592 static ETL_CONSTANT bool is_exact = false;
593 static ETL_CONSTANT int radix = 2;
594 static ETL_CONSTANT bool has_infinity = true;
595 static ETL_CONSTANT bool has_quiet_NaN = ETL_HAS_NAN;
596 static ETL_CONSTANT bool has_signaling_NaN = ETL_HAS_NAN;
597 static ETL_CONSTANT bool has_denorm_loss = false;
598 static ETL_CONSTANT bool is_iec559 = false;
599 static ETL_CONSTANT bool is_bounded = true;
600 static ETL_CONSTANT bool is_modulo = false;
601 static ETL_CONSTANT bool traps = false;
602 static ETL_CONSTANT bool tinyness_before = false;
603 static ETL_CONSTANT float_denorm_style has_denorm = denorm_indeterminate;
604 static ETL_CONSTANT float_round_style round_style = round_indeterminate;
605 };
606
607 template <typename T>
608 ETL_CONSTANT bool floating_point_limits_common<T>::is_specialized;
609
610 template <typename T>
611 ETL_CONSTANT bool floating_point_limits_common<T>::is_signed;
612
613 template <typename T>
614 ETL_CONSTANT bool floating_point_limits_common<T>::is_integer;
615
616 template <typename T>
617 ETL_CONSTANT bool floating_point_limits_common<T>::is_exact;
618
619 template <typename T>
620 ETL_CONSTANT int floating_point_limits_common<T>::radix;
621
622 template <typename T>
623 ETL_CONSTANT bool floating_point_limits_common<T>::has_infinity;
624
625 template <typename T>
626 ETL_CONSTANT bool floating_point_limits_common<T>::has_quiet_NaN;
627
628 template <typename T>
629 ETL_CONSTANT bool floating_point_limits_common<T>::has_signaling_NaN;
630
631 template <typename T>
632 ETL_CONSTANT bool floating_point_limits_common<T>::has_denorm_loss;
633
634 template <typename T>
635 ETL_CONSTANT bool floating_point_limits_common<T>::is_iec559;
636
637 template <typename T>
638 ETL_CONSTANT bool floating_point_limits_common<T>::is_bounded;
639
640 template <typename T>
641 ETL_CONSTANT bool floating_point_limits_common<T>::is_modulo;
642
643 template <typename T>
644 ETL_CONSTANT bool floating_point_limits_common<T>::traps;
645
646 template <typename T>
647 ETL_CONSTANT bool floating_point_limits_common<T>::tinyness_before;
648
649 template <typename T>
650 ETL_CONSTANT float_denorm_style floating_point_limits_common<T>::has_denorm;
651
652 template <typename T>
653 ETL_CONSTANT float_round_style floating_point_limits_common<T>::round_style;
654
655 //*********************************
656 // float
657 template <typename T = void>
658 struct floating_point_limits_float
659 {
660 static ETL_CONSTANT int digits = FLT_MANT_DIG;
661 static ETL_CONSTANT int digits10 = FLT_DIG;
662 static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(FLT_MANT_DIG) + 2;
663
664 static ETL_CONSTANT int min_exponent = FLT_MIN_EXP;
665 static ETL_CONSTANT int min_exponent10 = FLT_MIN_10_EXP;
666 static ETL_CONSTANT int max_exponent = FLT_MAX_EXP;
667 static ETL_CONSTANT int max_exponent10 = FLT_MAX_10_EXP;
668 };
669
670 template <typename T>
671 ETL_CONSTANT int floating_point_limits_float<T>::digits;
672
673 template <typename T>
674 ETL_CONSTANT int floating_point_limits_float<T>::digits10;
675
676 template <typename T>
677 ETL_CONSTANT int floating_point_limits_float<T>::max_digits10;
678
679 template <typename T>
680 ETL_CONSTANT int floating_point_limits_float<T>::min_exponent;
681
682 template <typename T>
683 ETL_CONSTANT int floating_point_limits_float<T>::min_exponent10;
684
685 template <typename T>
686 ETL_CONSTANT int floating_point_limits_float<T>::max_exponent;
687
688 template <typename T>
689 ETL_CONSTANT int floating_point_limits_float<T>::max_exponent10;
690
691 //*********************************
692 // double
693 template <typename T = void>
694 struct floating_point_limits_double
695 {
696 static ETL_CONSTANT int digits = DBL_MANT_DIG;
697 static ETL_CONSTANT int digits10 = DBL_DIG;
698 static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(DBL_MANT_DIG) + 2;
699
700 static ETL_CONSTANT int min_exponent = DBL_MIN_EXP;
701 static ETL_CONSTANT int min_exponent10 = DBL_MIN_10_EXP;
702 static ETL_CONSTANT int max_exponent = DBL_MAX_EXP;
703 static ETL_CONSTANT int max_exponent10 = DBL_MAX_10_EXP;
704 };
705
706 template <typename T>
707 ETL_CONSTANT int floating_point_limits_double<T>::digits;
708
709 template <typename T>
710 ETL_CONSTANT int floating_point_limits_double<T>::digits10;
711
712 template <typename T>
713 ETL_CONSTANT int floating_point_limits_double<T>::max_digits10;
714
715 template <typename T>
716 ETL_CONSTANT int floating_point_limits_double<T>::min_exponent;
717
718 template <typename T>
719 ETL_CONSTANT int floating_point_limits_double<T>::min_exponent10;
720
721 template <typename T>
722 ETL_CONSTANT int floating_point_limits_double<T>::max_exponent;
723
724 template <typename T>
725 ETL_CONSTANT int floating_point_limits_double<T>::max_exponent10;
726
727 //*********************************
728 // long double
729 template <typename T = void>
730 struct floating_point_limits_long_double
731 {
732 static ETL_CONSTANT int digits = LDBL_MANT_DIG;
733 static ETL_CONSTANT int digits10 = LDBL_DIG;
734 static ETL_CONSTANT int max_digits10 = ETL_LOG10_OF_2(LDBL_MANT_DIG) + 2;
735
736 static ETL_CONSTANT int min_exponent = LDBL_MIN_EXP;
737 static ETL_CONSTANT int min_exponent10 = LDBL_MIN_10_EXP;
738 static ETL_CONSTANT int max_exponent = LDBL_MAX_EXP;
739 static ETL_CONSTANT int max_exponent10 = LDBL_MAX_10_EXP;
740 };
741
742 template <typename T>
743 ETL_CONSTANT int floating_point_limits_long_double<T>::digits;
744
745 template <typename T>
746 ETL_CONSTANT int floating_point_limits_long_double<T>::digits10;
747
748 template <typename T>
749 ETL_CONSTANT int floating_point_limits_long_double<T>::max_digits10;
750
751 template <typename T>
752 ETL_CONSTANT int floating_point_limits_long_double<T>::min_exponent;
753
754 template <typename T>
755 ETL_CONSTANT int floating_point_limits_long_double<T>::min_exponent10;
756
757 template <typename T>
758 ETL_CONSTANT int floating_point_limits_long_double<T>::max_exponent;
759
760 template <typename T>
761 ETL_CONSTANT int floating_point_limits_long_double<T>::max_exponent10;
762 } // namespace private_limits
763
764 //***************************************************************************
765 // Default
766 template <typename T>
767 class numeric_limits;
768
769 template <typename T>
770 class numeric_limits<const T> : public numeric_limits<T>
771 {
772 };
773
774 template <typename T>
775 class numeric_limits<volatile T> : public numeric_limits<T>
776 {
777 };
778
779 template <typename T>
780 class numeric_limits<const volatile T> : public numeric_limits<T>
781 {
782 };
783
784 //***********************************
785 // bool
786 template <>
787 class numeric_limits<bool>
788 : public private_limits::integral_limits_common<>
789 , public private_limits::integral_limits_bool<>
790 {
791 public:
792
793 static ETL_CONSTEXPR bool min()
794 {
795 return false;
796 }
797 static ETL_CONSTEXPR bool max()
798 {
799 return true;
800 }
801 static ETL_CONSTEXPR bool lowest()
802 {
803 return false;
804 }
805 static ETL_CONSTEXPR bool epsilon()
806 {
807 return false;
808 }
809 static ETL_CONSTEXPR bool round_error()
810 {
811 return false;
812 }
813 static ETL_CONSTEXPR bool denorm_min()
814 {
815 return false;
816 }
817 static ETL_CONSTEXPR bool infinity()
818 {
819 return false;
820 }
821 static ETL_CONSTEXPR bool quiet_NaN()
822 {
823 return false;
824 }
825 static ETL_CONSTEXPR bool signaling_NaN()
826 {
827 return false;
828 }
829 };
830
831 //***************************************************************************
832 // char
833 template <>
834 class numeric_limits<char>
835 : public private_limits::integral_limits_common<>
836 , public private_limits::integral_limits_char<>
837 {
838 public:
839
840 static ETL_CONSTEXPR char min()
841 {
842 return char(CHAR_MIN);
843 }
844 static ETL_CONSTEXPR char max()
845 {
846 return char(CHAR_MAX);
847 }
848 static ETL_CONSTEXPR char lowest()
849 {
850 return char(CHAR_MIN);
851 }
852 static ETL_CONSTEXPR char epsilon()
853 {
854 return 0;
855 }
856 static ETL_CONSTEXPR char round_error()
857 {
858 return 0;
859 }
860 static ETL_CONSTEXPR char denorm_min()
861 {
862 return 0;
863 }
864 static ETL_CONSTEXPR char infinity()
865 {
866 return 0;
867 }
868 static ETL_CONSTEXPR char quiet_NaN()
869 {
870 return 0;
871 }
872 static ETL_CONSTEXPR char signaling_NaN()
873 {
874 return 0;
875 }
876 };
877
878 //***************************************************************************
879 // unsigned char
880 template <>
881 class numeric_limits<unsigned char>
882 : public private_limits::integral_limits_common<>
883 , public private_limits::integral_limits_unsigned_char<>
884 {
885 public:
886
887 static ETL_CONSTEXPR unsigned char min()
888 {
889 return 0U;
890 }
891 static ETL_CONSTEXPR unsigned char max()
892 {
893 return UCHAR_MAX;
894 }
895 static ETL_CONSTEXPR unsigned char lowest()
896 {
897 return 0U;
898 }
899 static ETL_CONSTEXPR unsigned char epsilon()
900 {
901 return 0U;
902 }
903 static ETL_CONSTEXPR unsigned char round_error()
904 {
905 return 0U;
906 }
907 static ETL_CONSTEXPR unsigned char denorm_min()
908 {
909 return 0U;
910 }
911 static ETL_CONSTEXPR unsigned char infinity()
912 {
913 return 0U;
914 }
915 static ETL_CONSTEXPR unsigned char quiet_NaN()
916 {
917 return 0U;
918 }
919 static ETL_CONSTEXPR unsigned char signaling_NaN()
920 {
921 return 0U;
922 }
923 };
924
925 //***************************************************************************
926 // signed char
927 template <>
928 class numeric_limits<signed char>
929 : public private_limits::integral_limits_common<>
930 , public private_limits::integral_limits_signed_char<>
931 {
932 public:
933
934 static ETL_CONSTEXPR signed char min()
935 {
936 return SCHAR_MIN;
937 }
938 static ETL_CONSTEXPR signed char max()
939 {
940 return SCHAR_MAX;
941 }
942 static ETL_CONSTEXPR signed char lowest()
943 {
944 return SCHAR_MIN;
945 }
946 static ETL_CONSTEXPR signed char epsilon()
947 {
948 return 0;
949 }
950 static ETL_CONSTEXPR signed char round_error()
951 {
952 return 0;
953 }
954 static ETL_CONSTEXPR signed char denorm_min()
955 {
956 return 0;
957 }
958 static ETL_CONSTEXPR signed char infinity()
959 {
960 return 0;
961 }
962 static ETL_CONSTEXPR signed char quiet_NaN()
963 {
964 return 0;
965 }
966 static ETL_CONSTEXPR signed char signaling_NaN()
967 {
968 return 0;
969 }
970 };
971
972 #if ETL_HAS_NATIVE_CHAR8_T
973 //***************************************************************************
974 // char8_t
975 template <>
976 class numeric_limits<char8_t>
977 : public private_limits::integral_limits_common<>
978 , public private_limits::integral_limits_char8_t<>
979 {
980 public:
981
982 static ETL_CONSTEXPR char8_t min()
983 {
984 return char8_t(CHAR_MIN);
985 }
986 static ETL_CONSTEXPR char8_t max()
987 {
988 return char8_t(CHAR_MAX);
989 }
990 static ETL_CONSTEXPR char8_t lowest()
991 {
992 return char8_t(CHAR_MIN);
993 }
994 static ETL_CONSTEXPR char8_t epsilon()
995 {
996 return 0;
997 }
998 static ETL_CONSTEXPR char8_t round_error()
999 {
1000 return 0;
1001 }
1002 static ETL_CONSTEXPR char8_t denorm_min()
1003 {
1004 return 0;
1005 }
1006 static ETL_CONSTEXPR char8_t infinity()
1007 {
1008 return 0;
1009 }
1010 static ETL_CONSTEXPR char8_t quiet_NaN()
1011 {
1012 return 0;
1013 }
1014 static ETL_CONSTEXPR char8_t signaling_NaN()
1015 {
1016 return 0;
1017 }
1018 };
1019 #endif
1020
1021 #if ETL_HAS_NATIVE_CHAR16_T
1022 //***************************************************************************
1023 // char16_t
1024 template <>
1025 class numeric_limits<char16_t>
1026 : public private_limits::integral_limits_common<>
1027 , public private_limits::integral_limits_char16_t<>
1028 {
1029 public:
1030
1031 static ETL_CONSTEXPR char16_t min()
1032 {
1033 return 0U;
1034 }
1035 static ETL_CONSTEXPR char16_t max()
1036 {
1037 return UINT_LEAST16_MAX;
1038 }
1039 static ETL_CONSTEXPR char16_t lowest()
1040 {
1041 return 0U;
1042 }
1043 static ETL_CONSTEXPR char16_t epsilon()
1044 {
1045 return 0U;
1046 }
1047 static ETL_CONSTEXPR char16_t round_error()
1048 {
1049 return 0U;
1050 }
1051 static ETL_CONSTEXPR char16_t denorm_min()
1052 {
1053 return 0U;
1054 }
1055 static ETL_CONSTEXPR char16_t infinity()
1056 {
1057 return 0U;
1058 }
1059 static ETL_CONSTEXPR char16_t quiet_NaN()
1060 {
1061 return 0U;
1062 }
1063 static ETL_CONSTEXPR char16_t signaling_NaN()
1064 {
1065 return 0U;
1066 }
1067 };
1068 #endif
1069
1070 #if ETL_HAS_NATIVE_CHAR32_T
1071 //***************************************************************************
1072 // char32_t
1073 template <>
1074 class numeric_limits<char32_t>
1075 : public private_limits::integral_limits_common<>
1076 , public private_limits::integral_limits_char32_t<>
1077 {
1078 public:
1079
1080 static ETL_CONSTEXPR char32_t min()
1081 {
1082 return 0U;
1083 }
1084 static ETL_CONSTEXPR char32_t max()
1085 {
1086 return UINT_LEAST32_MAX;
1087 }
1088 static ETL_CONSTEXPR char32_t lowest()
1089 {
1090 return 0U;
1091 }
1092 static ETL_CONSTEXPR char32_t epsilon()
1093 {
1094 return 0U;
1095 }
1096 static ETL_CONSTEXPR char32_t round_error()
1097 {
1098 return 0U;
1099 }
1100 static ETL_CONSTEXPR char32_t denorm_min()
1101 {
1102 return 0U;
1103 }
1104 static ETL_CONSTEXPR char32_t infinity()
1105 {
1106 return 0U;
1107 }
1108 static ETL_CONSTEXPR char32_t quiet_NaN()
1109 {
1110 return 0U;
1111 }
1112 static ETL_CONSTEXPR char32_t signaling_NaN()
1113 {
1114 return 0U;
1115 }
1116 };
1117 #endif
1118
1119 //***************************************************************************
1120 // wchar_t
1121 template <>
1122 class numeric_limits<wchar_t>
1123 : public private_limits::integral_limits_common<>
1124 , public private_limits::integral_limits_wchar_t<>
1125 {
1126 public:
1127
1128 static ETL_CONSTEXPR wchar_t min()
1129 {
1130 return WCHAR_MIN;
1131 }
1132 static ETL_CONSTEXPR wchar_t max()
1133 {
1134 return WCHAR_MAX;
1135 }
1136 static ETL_CONSTEXPR wchar_t lowest()
1137 {
1138 return WCHAR_MIN;
1139 }
1140 static ETL_CONSTEXPR wchar_t epsilon()
1141 {
1142 return wchar_t(0);
1143 }
1144 static ETL_CONSTEXPR wchar_t round_error()
1145 {
1146 return wchar_t(0);
1147 }
1148 static ETL_CONSTEXPR wchar_t denorm_min()
1149 {
1150 return wchar_t(0);
1151 }
1152 static ETL_CONSTEXPR wchar_t infinity()
1153 {
1154 return wchar_t(0);
1155 }
1156 static ETL_CONSTEXPR wchar_t quiet_NaN()
1157 {
1158 return wchar_t(0);
1159 }
1160 static ETL_CONSTEXPR wchar_t signaling_NaN()
1161 {
1162 return wchar_t(0);
1163 }
1164 };
1165
1166 //***************************************************************************
1167 // short
1168 template <>
1169 class numeric_limits<short>
1170 : public private_limits::integral_limits_common<>
1171 , public private_limits::integral_limits_short<>
1172 {
1173 public:
1174
1175 static ETL_CONSTEXPR short min()
1176 {
1177 return SHRT_MIN;
1178 }
1179 static ETL_CONSTEXPR short max()
1180 {
1181 return SHRT_MAX;
1182 }
1183 static ETL_CONSTEXPR short lowest()
1184 {
1185 return SHRT_MIN;
1186 }
1187 static ETL_CONSTEXPR short epsilon()
1188 {
1189 return 0;
1190 }
1191 static ETL_CONSTEXPR short round_error()
1192 {
1193 return 0;
1194 }
1195 static ETL_CONSTEXPR short denorm_min()
1196 {
1197 return 0;
1198 }
1199 static ETL_CONSTEXPR short infinity()
1200 {
1201 return 0;
1202 }
1203 static ETL_CONSTEXPR short quiet_NaN()
1204 {
1205 return 0;
1206 }
1207 static ETL_CONSTEXPR short signaling_NaN()
1208 {
1209 return 0;
1210 }
1211 };
1212
1213 //***************************************************************************
1214 // unsigned short
1215 template <>
1216 class numeric_limits<unsigned short>
1217 : public private_limits::integral_limits_common<>
1218 , public private_limits::integral_limits_unsigned_short<>
1219 {
1220 public:
1221
1222 static ETL_CONSTEXPR unsigned short min()
1223 {
1224 return 0U;
1225 }
1226 static ETL_CONSTEXPR unsigned short max()
1227 {
1228 return USHRT_MAX;
1229 }
1230 static ETL_CONSTEXPR unsigned short lowest()
1231 {
1232 return 0U;
1233 }
1234 static ETL_CONSTEXPR unsigned short epsilon()
1235 {
1236 return 0U;
1237 }
1238 static ETL_CONSTEXPR unsigned short round_error()
1239 {
1240 return 0U;
1241 }
1242 static ETL_CONSTEXPR unsigned short denorm_min()
1243 {
1244 return 0U;
1245 }
1246 static ETL_CONSTEXPR unsigned short infinity()
1247 {
1248 return 0U;
1249 }
1250 static ETL_CONSTEXPR unsigned short quiet_NaN()
1251 {
1252 return 0U;
1253 }
1254 static ETL_CONSTEXPR unsigned short signaling_NaN()
1255 {
1256 return 0U;
1257 }
1258 };
1259
1260 //***************************************************************************
1261 // int
1262 template <>
1263 class numeric_limits<int>
1264 : public private_limits::integral_limits_common<>
1265 , public private_limits::integral_limits_int<>
1266 {
1267 public:
1268
1269 static ETL_CONSTEXPR int min()
1270 {
1271 return INT_MIN;
1272 }
1273 static ETL_CONSTEXPR int max()
1274 {
1275 return INT_MAX;
1276 }
1277 static ETL_CONSTEXPR int lowest()
1278 {
1279 return INT_MIN;
1280 }
1281 static ETL_CONSTEXPR int epsilon()
1282 {
1283 return 0;
1284 }
1285 static ETL_CONSTEXPR int round_error()
1286 {
1287 return 0;
1288 }
1289 static ETL_CONSTEXPR int denorm_min()
1290 {
1291 return 0;
1292 }
1293 static ETL_CONSTEXPR int infinity()
1294 {
1295 return 0;
1296 }
1297 static ETL_CONSTEXPR int quiet_NaN()
1298 {
1299 return 0;
1300 }
1301 static ETL_CONSTEXPR int signaling_NaN()
1302 {
1303 return 0;
1304 }
1305 };
1306
1307 //***************************************************************************
1308 // unsigned int
1309 template <>
1310 class numeric_limits<unsigned int>
1311 : public private_limits::integral_limits_common<>
1312 , public private_limits::integral_limits_unsigned_int<>
1313 {
1314 public:
1315
1316 static ETL_CONSTEXPR unsigned int min()
1317 {
1318 return 0U;
1319 }
1320 static ETL_CONSTEXPR unsigned int max()
1321 {
1322 return UINT_MAX;
1323 }
1324 static ETL_CONSTEXPR unsigned int lowest()
1325 {
1326 return 0U;
1327 }
1328 static ETL_CONSTEXPR unsigned int epsilon()
1329 {
1330 return 0U;
1331 }
1332 static ETL_CONSTEXPR unsigned int round_error()
1333 {
1334 return 0U;
1335 }
1336 static ETL_CONSTEXPR unsigned int denorm_min()
1337 {
1338 return 0U;
1339 }
1340 static ETL_CONSTEXPR unsigned int infinity()
1341 {
1342 return 0U;
1343 }
1344 static ETL_CONSTEXPR unsigned int quiet_NaN()
1345 {
1346 return 0U;
1347 }
1348 static ETL_CONSTEXPR unsigned int signaling_NaN()
1349 {
1350 return 0U;
1351 }
1352 };
1353
1354 //***************************************************************************
1355 // long
1356 template <>
1357 class numeric_limits<long>
1358 : public private_limits::integral_limits_common<>
1359 , public private_limits::integral_limits_long<>
1360 {
1361 public:
1362
1363 static ETL_CONSTEXPR long min()
1364 {
1365 return LONG_MIN;
1366 }
1367 static ETL_CONSTEXPR long max()
1368 {
1369 return LONG_MAX;
1370 }
1371 static ETL_CONSTEXPR long lowest()
1372 {
1373 return LONG_MIN;
1374 }
1375 static ETL_CONSTEXPR long epsilon()
1376 {
1377 return 0;
1378 }
1379 static ETL_CONSTEXPR long round_error()
1380 {
1381 return 0;
1382 }
1383 static ETL_CONSTEXPR long denorm_min()
1384 {
1385 return 0;
1386 }
1387 static ETL_CONSTEXPR long infinity()
1388 {
1389 return 0;
1390 }
1391 static ETL_CONSTEXPR long quiet_NaN()
1392 {
1393 return 0;
1394 }
1395 static ETL_CONSTEXPR long signaling_NaN()
1396 {
1397 return 0;
1398 }
1399 };
1400
1401 //***************************************************************************
1402 // unsigned long
1403 template <>
1404 class numeric_limits<unsigned long>
1405 : public private_limits::integral_limits_common<>
1406 , public private_limits::integral_limits_unsigned_long<>
1407 {
1408 public:
1409
1410 static ETL_CONSTEXPR unsigned long min()
1411 {
1412 return 0U;
1413 }
1414 static ETL_CONSTEXPR unsigned long max()
1415 {
1416 return ULONG_MAX;
1417 }
1418 static ETL_CONSTEXPR unsigned long lowest()
1419 {
1420 return 0U;
1421 }
1422 static ETL_CONSTEXPR unsigned long epsilon()
1423 {
1424 return 0U;
1425 }
1426 static ETL_CONSTEXPR unsigned long round_error()
1427 {
1428 return 0U;
1429 }
1430 static ETL_CONSTEXPR unsigned long denorm_min()
1431 {
1432 return 0U;
1433 }
1434 static ETL_CONSTEXPR unsigned long infinity()
1435 {
1436 return 0U;
1437 }
1438 static ETL_CONSTEXPR unsigned long quiet_NaN()
1439 {
1440 return 0U;
1441 }
1442 static ETL_CONSTEXPR unsigned long signaling_NaN()
1443 {
1444 return 0U;
1445 }
1446 };
1447
1448 //***************************************************************************
1449 // long long
1450 template <>
1451 class numeric_limits<long long>
1452 : public private_limits::integral_limits_common<>
1453 , public private_limits::integral_limits_long_long<>
1454 {
1455 public:
1456
1457 static ETL_CONSTEXPR long long min()
1458 {
1459 return LLONG_MIN;
1460 }
1461 static ETL_CONSTEXPR long long max()
1462 {
1463 return LLONG_MAX;
1464 }
1465 static ETL_CONSTEXPR long long lowest()
1466 {
1467 return LLONG_MIN;
1468 }
1469 static ETL_CONSTEXPR long long epsilon()
1470 {
1471 return 0;
1472 }
1473 static ETL_CONSTEXPR long long round_error()
1474 {
1475 return 0;
1476 }
1477 static ETL_CONSTEXPR long long denorm_min()
1478 {
1479 return 0;
1480 }
1481 static ETL_CONSTEXPR long long infinity()
1482 {
1483 return 0;
1484 }
1485 static ETL_CONSTEXPR long long quiet_NaN()
1486 {
1487 return 0;
1488 }
1489 static ETL_CONSTEXPR long long signaling_NaN()
1490 {
1491 return 0;
1492 }
1493 };
1494
1495 //***************************************************************************
1496 // unsigned long long
1497 template <>
1498 class numeric_limits<unsigned long long>
1499 : public private_limits::integral_limits_common<>
1500 , public private_limits::integral_limits_unsigned_long_long<>
1501 {
1502 public:
1503
1504 static ETL_CONSTEXPR unsigned long long min()
1505 {
1506 return 0U;
1507 }
1508 static ETL_CONSTEXPR unsigned long long max()
1509 {
1510 return ULLONG_MAX;
1511 }
1512 static ETL_CONSTEXPR unsigned long long lowest()
1513 {
1514 return 0U;
1515 }
1516 static ETL_CONSTEXPR unsigned long long epsilon()
1517 {
1518 return 0U;
1519 }
1520 static ETL_CONSTEXPR unsigned long long round_error()
1521 {
1522 return 0U;
1523 }
1524 static ETL_CONSTEXPR unsigned long long denorm_min()
1525 {
1526 return 0U;
1527 }
1528 static ETL_CONSTEXPR unsigned long long infinity()
1529 {
1530 return 0U;
1531 }
1532 static ETL_CONSTEXPR unsigned long long quiet_NaN()
1533 {
1534 return 0U;
1535 }
1536 static ETL_CONSTEXPR unsigned long long signaling_NaN()
1537 {
1538 return 0U;
1539 }
1540 };
1541
1542 //***************************************************************************
1543 // float
1544 template <>
1545 class numeric_limits<float>
1546 : public private_limits::floating_point_limits_common<>
1547 , public private_limits::floating_point_limits_float<>
1548 {
1549 public:
1550
1551 static ETL_CONSTEXPR float min()
1552 {
1553 return FLT_MIN;
1554 }
1555 static ETL_CONSTEXPR float max()
1556 {
1557 return FLT_MAX;
1558 }
1559 static ETL_CONSTEXPR float lowest()
1560 {
1561 return -FLT_MAX;
1562 }
1563 static ETL_CONSTEXPR float epsilon()
1564 {
1565 return FLT_EPSILON;
1566 }
1567 static ETL_CONSTEXPR float denorm_min()
1568 {
1569 return FLT_MIN;
1570 }
1571 static ETL_CONSTEXPR float infinity()
1572 {
1573 return HUGE_VALF;
1574 }
1575 static float round_error()
1576 {
1577 return 0.5f;
1578 }
1579 static float quiet_NaN()
1580 {
1581 return ETL_NANF;
1582 }
1583 static float signaling_NaN()
1584 {
1585 return ETL_NANF;
1586 }
1587 };
1588
1589 //***************************************************************************
1590 // double
1591 template <>
1592 class numeric_limits<double>
1593 : public private_limits::floating_point_limits_common<>
1594 , public private_limits::floating_point_limits_double<>
1595 {
1596 public:
1597
1598 static ETL_CONSTEXPR double min()
1599 {
1600 return DBL_MIN;
1601 }
1602 static ETL_CONSTEXPR double max()
1603 {
1604 return DBL_MAX;
1605 }
1606 static ETL_CONSTEXPR double lowest()
1607 {
1608 return -DBL_MAX;
1609 }
1610 static ETL_CONSTEXPR double epsilon()
1611 {
1612 return DBL_EPSILON;
1613 }
1614 static ETL_CONSTEXPR double denorm_min()
1615 {
1616 return DBL_MIN;
1617 }
1618 static ETL_CONSTEXPR double infinity()
1619 {
1620 return HUGE_VAL;
1621 }
1622 static double round_error()
1623 {
1624 return 0.5;
1625 }
1626 static double quiet_NaN()
1627 {
1628 return ETL_NAN;
1629 }
1630 static double signaling_NaN()
1631 {
1632 return ETL_NAN;
1633 }
1634 };
1635
1636 //***************************************************************************
1637 // long double
1638 template <>
1639 class numeric_limits<long double>
1640 : public private_limits::floating_point_limits_common<>
1641 , public private_limits::floating_point_limits_long_double<>
1642 {
1643 public:
1644
1645 static ETL_CONSTEXPR long double min()
1646 {
1647 return LDBL_MIN;
1648 }
1649 static ETL_CONSTEXPR long double max()
1650 {
1651 return LDBL_MAX;
1652 }
1653 static ETL_CONSTEXPR long double lowest()
1654 {
1655 return -LDBL_MAX;
1656 }
1657 static ETL_CONSTEXPR long double epsilon()
1658 {
1659 return LDBL_EPSILON;
1660 }
1661 static ETL_CONSTEXPR long double denorm_min()
1662 {
1663 return LDBL_MIN;
1664 }
1665 static ETL_CONSTEXPR long double infinity()
1666 {
1667 return HUGE_VALL;
1668 }
1669 static long double round_error()
1670 {
1671 return 0.5L;
1672 }
1673 static long double quiet_NaN()
1674 {
1675 return ETL_NANL;
1676 }
1677 static long double signaling_NaN()
1678 {
1679 return ETL_NANL;
1680 }
1681 };
1682} // namespace etl
1683
1684#else
1685
1686 #include <limits>
1687
1688namespace etl
1689{
1690 enum float_round_style
1691 {
1692 round_indeterminate = std::round_indeterminate,
1693 round_toward_zero = std::round_toward_zero,
1694 round_to_nearest = std::round_to_nearest,
1695 round_toward_infinity = std::round_toward_infinity,
1696 round_toward_neg_infinity = std::round_toward_neg_infinity,
1697 };
1698
1700 enum float_denorm_style
1701 {
1702 denorm_indeterminate = std::denorm_indeterminate,
1703 denorm_absent = std::denorm_absent,
1704 denorm_present = std::denorm_present
1705 };
1706 #include "private/diagnostic_pop.h"
1707
1708 #if ETL_USING_CPP11
1709 template <typename T>
1710 using numeric_limits = std::numeric_limits<T>;
1711 #else
1712 template <typename T>
1713 class numeric_limits : public std::numeric_limits<T>
1714 {
1715 };
1716 #endif
1717} // namespace etl
1718#endif
1719
1720#if defined(ETL_COMPILER_MICROSOFT)
1721 #pragma warning(pop)
1722#endif
1723
1724#include "private/minmax_pop.h"
1725
1726#endif
Definition limits.h:1714
Definition absolute.h:40