halfLimits.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. ///////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
  4. // Digital Ltd. LLC
  5. //
  6. // All rights reserved.
  7. //
  8. // Redistribution and use in source and binary forms, with or without
  9. // modification, are permitted provided that the following conditions are
  10. // met:
  11. // * Redistributions of source code must retain the above copyright
  12. // notice, this list of conditions and the following disclaimer.
  13. // * Redistributions in binary form must reproduce the above
  14. // copyright notice, this list of conditions and the following disclaimer
  15. // in the documentation and/or other materials provided with the
  16. // distribution.
  17. // * Neither the name of Industrial Light & Magic nor the names of
  18. // its contributors may be used to endorse or promote products derived
  19. // from this software without specific prior written permission.
  20. //
  21. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. //
  33. ///////////////////////////////////////////////////////////////////////////
  34. // Primary authors:
  35. // Florian Kainz <kainz@ilm.com>
  36. // Rod Bogart <rgb@ilm.com>
  37. #ifndef INCLUDED_HALF_LIMITS_H
  38. #define INCLUDED_HALF_LIMITS_H
  39. //------------------------------------------------------------------------
  40. //
  41. // C++ standard library-style numeric_limits for class half
  42. //
  43. //------------------------------------------------------------------------
  44. #include <limits>
  45. #include "half.h"
  46. namespace std {
  47. template <>
  48. class numeric_limits <half>
  49. {
  50. public:
  51. static const bool is_specialized = true;
  52. static half min () throw () {return HALF_NRM_MIN;}
  53. static half max () throw () {return HALF_MAX;}
  54. static const int digits = HALF_MANT_DIG;
  55. static const int digits10 = HALF_DIG;
  56. static const bool is_signed = true;
  57. static const bool is_integer = false;
  58. static const bool is_exact = false;
  59. static const int radix = HALF_RADIX;
  60. static half epsilon () throw () {return HALF_EPSILON;}
  61. static half round_error () throw () {return HALF_EPSILON / 2;}
  62. static const int min_exponent = HALF_MIN_EXP;
  63. static const int min_exponent10 = HALF_MIN_10_EXP;
  64. static const int max_exponent = HALF_MAX_EXP;
  65. static const int max_exponent10 = HALF_MAX_10_EXP;
  66. static const bool has_infinity = true;
  67. static const bool has_quiet_NaN = true;
  68. static const bool has_signaling_NaN = true;
  69. static const float_denorm_style has_denorm = denorm_present;
  70. static const bool has_denorm_loss = false;
  71. static half infinity () throw () {return half::posInf();}
  72. static half quiet_NaN () throw () {return half::qNan();}
  73. static half signaling_NaN () throw () {return half::sNan();}
  74. static half denorm_min () throw () {return HALF_MIN;}
  75. static const bool is_iec559 = false;
  76. static const bool is_bounded = false;
  77. static const bool is_modulo = false;
  78. static const bool traps = true;
  79. static const bool tinyness_before = false;
  80. static const float_round_style round_style = round_to_nearest;
  81. #if __cplusplus >= 201103L
  82. // C++11 additions.
  83. static constexpr int max_digits10 = HALF_DECIMAL_DIG;
  84. static half lowest () {return -HALF_MAX;}
  85. #endif
  86. };
  87. } // namespace std
  88. #endif