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