Embedded Template Library  1.0
limits.h
Go to the documentation of this file.
1 
3 /******************************************************************************
4 The MIT License(MIT)
5 
6 Embedded Template Library.
7 https://github.com/ETLCPP/etl
8 https://www.etlcpp.com
9 
10 Copyright(c) 2018 jwellbelove
11 
12 Permission is hereby granted, free of charge, to any person obtaining a copy
13 of this software and associated documentation files(the "Software"), to deal
14 in the Software without restriction, including without limitation the rights
15 to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16 copies of the Software, and to permit persons to whom the Software is
17 furnished to do so, subject to the following conditions :
18 
19 The above copyright notice and this permission notice shall be included in all
20 copies or substantial portions of the Software.
21 
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 SOFTWARE.
29 ******************************************************************************/
30 
31 #ifndef ETL_LIMITS_INCLUDED
32 #define ETL_LIMITS_INCLUDED
33 
34 #include "platform.h"
35 #include "type_traits.h"
36 #include "char_traits.h"
37 #include "integral_limits.h"
38 
39 #if ETL_NOT_USING_STL && defined(ETL_COMPILER_ARM5) && !defined(__USE_C99_MATH)
40  // Required for nan, nanf, nanl
41  #define __USE_C99_MATH
42 #endif
43 
44 #include <limits.h>
45 #include <stdint.h>
46 #include <float.h>
47 #include <math.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(ETL_NO_HUGE_VAL_SUPPORT)
58  #ifndef HUGE_VAL
59  #define HUGE_VAL (1.0e999999999)
60  #endif
61 
62  #ifndef HUGE_VALF
63  #define HUGE_VALF (1.0e999999999F)
64  #endif
65 
66  #ifndef HUGE_VALL
67  #define HUGE_VALL (1.0e999999999L)
68  #endif
69 #endif
70 
71 #if defined(ETL_NO_CPP_NAN_SUPPORT)
72  #if defined(NAN)
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
77  #else
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
82  #endif
83 #else
84  #define ETL_NAN nan("")
85  #define ETL_NANF nanf("")
86  #define ETL_NANL nanl("")
87  #define ETL_HAS_NAN true
88 #endif
89 
90 #if !defined(LDBL_MIN) && defined(DBL_MIN)
91  // Looks like we don't have those macros defined.
92  // That probably means that 'long double' is the same size as 'double'.
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
103 #endif
104 
105 namespace etl
106 {
107  enum float_round_style
108  {
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,
114  };
115 
116  enum float_denorm_style
117  {
118  denorm_indeterminate = -1,
119  denorm_absent = 0,
120  denorm_present = 1
121  };
122 
123 
124  class etl_integral_limits
125  {
126  public:
127 
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;
147  };
148 
149  class etl_floating_point_limits
150  {
151  public:
152 
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;
169 
170  static float round_error() { return float(0.5); }
171  };
172 
173  //***************************************************************************
174  // Default
175  template <typename T>
176  class numeric_limits;
177 
178  template <typename T>
179  class numeric_limits<const T> : public numeric_limits<T> { };
180 
181  template <typename T>
182  class numeric_limits<volatile T> : public numeric_limits<T> { };
183 
184  template <typename T>
185  class numeric_limits<const volatile T> : public numeric_limits<T> { };
186 
187  //***************************************************************************
188  // bool
189  template<>
190  class numeric_limits<bool> : public etl_integral_limits
191  {
192  public:
193 
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;
198 
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; }
208  };
209 
210  //***************************************************************************
211  // char
212  template<>
213  class numeric_limits<char> : public etl_integral_limits
214  {
215  public:
216 
217  static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char)) - (etl::is_signed<char>::value ? 1 : 0);
218  static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
219  static ETL_CONSTANT bool is_signed = etl::is_signed<char>::value;
220  static ETL_CONSTANT bool is_modulo = false;
221 
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; }
231  };
232 
233  //***************************************************************************
234  // unsigned char
235  template<>
236  class numeric_limits<unsigned char> : public etl_integral_limits
237  {
238  public:
239 
240  static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned char)) - (etl::is_signed<unsigned char>::value ? 1 : 0);
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;
244 
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; }
254  };
255 
256  //***************************************************************************
257  // signed char
258  template<>
259  class numeric_limits<signed char> : public etl_integral_limits
260  {
261  public:
262 
263  static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char)) - (etl::is_signed<char>::value ? 1 : 0);
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;
267 
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; }
277  };
278 
279 #if (ETL_NO_LARGE_CHAR_SUPPORT == false)
280  //***************************************************************************
281  // char16_t
282  template<>
283  class numeric_limits<char16_t> : public etl_integral_limits
284  {
285  public:
286 
287  static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char16_t)) - (etl::is_signed<char16_t>::value ? 1 : 0);
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;
291 
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; }
301  };
302 
303  //***************************************************************************
304  // char32_t
305  template<>
306  class numeric_limits<char32_t> : public etl_integral_limits
307  {
308  public:
309 
310  static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(char32_t)) - (etl::is_signed<char32_t>::value ? 1 : 0);
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;
314 
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; }
324  };
325 
326 #endif
327 
328  //***************************************************************************
329  // wchar_t
330  template<>
331  class numeric_limits<wchar_t> : public etl_integral_limits
332  {
333  public:
334 
335  static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(wchar_t)) - (etl::is_signed<wchar_t>::value ? 1 : 0);
336  static ETL_CONSTANT int digits10 = ETL_LOG10_OF_2(digits);
337  static ETL_CONSTANT bool is_signed = etl::is_signed<wchar_t>::value;
338  static ETL_CONSTANT bool is_modulo = etl::is_unsigned<wchar_t>::value;
339 
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); }
349  };
350 
351  //***************************************************************************
352  // short
353  template<>
354  class numeric_limits<short> : public etl_integral_limits
355  {
356  public:
357 
358  static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(short)) - (etl::is_signed<short>::value ? 1 : 0);
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;
362 
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; }
372  };
373 
374  //***************************************************************************
375  // unsigned short
376  template<>
377  class numeric_limits<unsigned short> : public etl_integral_limits
378  {
379  public:
380 
381  static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned short)) - (etl::is_signed<unsigned short>::value ? 1 : 0);
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;
385 
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; }
395 
396  };
397 
398  //***************************************************************************
399  // int
400  template<>
401  class numeric_limits<int> : public etl_integral_limits
402  {
403  public:
404 
405  static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(int)) - (etl::is_signed<int>::value ? 1 : 0);
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;
409 
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; }
419  };
420 
421  //***************************************************************************
422  // unsigned int
423  template<>
424  class numeric_limits<unsigned int> : public etl_integral_limits
425  {
426  public:
427 
428  static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned int)) - (etl::is_signed<unsigned int>::value ? 1 : 0);
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;
432 
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; }
442  };
443 
444  //***************************************************************************
445  // long
446  template<>
447  class numeric_limits<long> : public etl_integral_limits
448  {
449  public:
450 
451  static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(long)) - (etl::is_signed<long>::value ? 1 : 0);
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;
455 
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; }
465  };
466 
467  //***************************************************************************
468  // unsigned long
469  template<>
470  class numeric_limits<unsigned long> : public etl_integral_limits
471  {
472  public:
473 
474  static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned long)) - (etl::is_signed<unsigned long>::value ? 1 : 0);
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;
478 
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; }
488  };
489 
490  //***************************************************************************
491  // long long
492  template<>
493  class numeric_limits<long long> : public etl_integral_limits
494  {
495  public:
496 
497  static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(long long)) - (etl::is_signed<long long>::value ? 1 : 0);
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;
501 
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; }
511  };
512 
513  //***************************************************************************
514  // unsigned long long
515  template<>
516  class numeric_limits<unsigned long long> : public etl_integral_limits
517  {
518  public:
519 
520  static ETL_CONSTANT int digits = (CHAR_BIT * sizeof(unsigned long long)) - (etl::is_signed<unsigned long long>::value ? 1 : 0);
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;
524 
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; }
534  };
535 
536  //***************************************************************************
537  // float
538  template<>
539  class numeric_limits<float> : public etl_floating_point_limits
540  {
541  public:
542 
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; }
551 
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;
555 
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;
560  };
561 
562  //***************************************************************************
563  // double
564  template<>
565  class numeric_limits<double> : public etl_floating_point_limits
566  {
567  public:
568 
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; }
577 
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;
581 
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;
586  };
587 
588  //***************************************************************************
589  // long double
590  template<>
591  class numeric_limits<long double> : public etl_floating_point_limits
592  {
593  public:
594 
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; }
603 
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;
607 
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;
612  };
613 }
614 
615 #else
616 
617 #include <limits>
618 
619 namespace etl
620 {
621  enum float_round_style
622  {
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,
628  };
629 
630  enum float_denorm_style
631  {
632  denorm_indeterminate = std::denorm_indeterminate,
633  denorm_absent = std::denorm_absent,
634  denorm_present = std::denorm_present
635  };
636 
637  template <typename T>
638  class numeric_limits : public std::numeric_limits<T>
639  {
640  };
641 }
642 #endif
643 
644 #if defined(ETL_COMPILER_MICROSOFT)
645  #pragma warning(pop)
646 #endif
647 
648 #endif
Definition: limits.h:639
is_signed
Definition: type_traits_generator.h:951
is_unsigned
Definition: type_traits_generator.h:961
Definition: absolute.h:37