诸暨麻将添加redis
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

90 lines
4.2 KiB

  1. // Protocol Buffers - Google's data interchange format
  2. // Copyright 2008 Google Inc. All rights reserved.
  3. // https://developers.google.com/protocol-buffers/
  4. //
  5. // Redistribution and use in source and binary forms, with or without
  6. // modification, are permitted provided that the following conditions are
  7. // met:
  8. //
  9. // * Redistributions of source code must retain the above copyright
  10. // notice, this list of conditions and the following disclaimer.
  11. // * Redistributions in binary form must reproduce the above
  12. // copyright notice, this list of conditions and the following disclaimer
  13. // in the documentation and/or other materials provided with the
  14. // distribution.
  15. // * Neither the name of Google Inc. nor the names of its
  16. // contributors may be used to endorse or promote products derived from
  17. // this software without specific prior written permission.
  18. //
  19. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. // All Rights Reserved.
  31. //
  32. // Author: Maxim Lifantsev
  33. //
  34. #include <google/protobuf/stubs/mathlimits.h>
  35. #include <google/protobuf/stubs/common.h>
  36. namespace google {
  37. namespace protobuf {
  38. // http://en.wikipedia.org/wiki/Quadruple_precision_floating-point_format#Double-double_arithmetic
  39. // With some compilers (gcc 4.6.x) on some platforms (powerpc64),
  40. // "long double" is implemented as a pair of double: "double double" format.
  41. // This causes a problem with epsilon (eps).
  42. // eps is the smallest positive number such that 1.0 + eps > 1.0
  43. //
  44. // Normal format: 1.0 + e = 1.0...01 // N-1 zeros for N fraction bits
  45. // D-D format: 1.0 + e = 1.000...0001 // epsilon can be very small
  46. //
  47. // In the normal format, 1.0 + e has to fit in one stretch of bits.
  48. // The maximum rounding error is half of eps.
  49. //
  50. // In the double-double format, 1.0 + e splits across two doubles:
  51. // 1.0 in the high double, e in the low double, and they do not have to
  52. // be contiguous. The maximum rounding error on a value close to 1.0 is
  53. // much larger than eps.
  54. //
  55. // Some code checks for errors by comparing a computed value to a golden
  56. // value +/- some multiple of the maximum rounding error. The maximum
  57. // rounding error is not available so we use eps as an approximation
  58. // instead. That fails when long double is in the double-double format.
  59. // Therefore, we define kStdError as a multiple of
  60. // max(DBL_EPSILON * DBL_EPSILON, kEpsilon) rather than a multiple of kEpsilon.
  61. #define DEF_FP_LIMITS(Type, PREFIX) \
  62. const Type MathLimits<Type>::kPosMin = PREFIX##_MIN; \
  63. const Type MathLimits<Type>::kPosMax = PREFIX##_MAX; \
  64. const Type MathLimits<Type>::kMin = -MathLimits<Type>::kPosMax; \
  65. const Type MathLimits<Type>::kMax = MathLimits<Type>::kPosMax; \
  66. const Type MathLimits<Type>::kNegMin = -MathLimits<Type>::kPosMin; \
  67. const Type MathLimits<Type>::kNegMax = -MathLimits<Type>::kPosMax; \
  68. const Type MathLimits<Type>::kEpsilon = PREFIX##_EPSILON; \
  69. /* 32 is 5 bits of mantissa error; should be adequate for common errors */ \
  70. const Type MathLimits<Type>::kStdError = \
  71. 32 * (DBL_EPSILON * DBL_EPSILON > MathLimits<Type>::kEpsilon \
  72. ? DBL_EPSILON * DBL_EPSILON : MathLimits<Type>::kEpsilon); \
  73. const Type MathLimits<Type>::kNaN = HUGE_VAL - HUGE_VAL; \
  74. const Type MathLimits<Type>::kPosInf = HUGE_VAL; \
  75. const Type MathLimits<Type>::kNegInf = -HUGE_VAL;
  76. DEF_FP_LIMITS(float, FLT)
  77. DEF_FP_LIMITS(double, DBL)
  78. DEF_FP_LIMITS(long double, LDBL);
  79. #undef DEF_FP_LIMITS
  80. } // namespace protobuf
  81. } // namespace google