Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:31:47

0001 // Copyright 2021 The Abseil Authors
0002 //
0003 // Licensed under the Apache License, Version 2.0 (the "License");
0004 // you may not use this file except in compliance with the License.
0005 // You may obtain a copy of the License at
0006 //
0007 //     https://www.apache.org/licenses/LICENSE-2.0
0008 //
0009 // Unless required by applicable law or agreed to in writing, software
0010 // distributed under the License is distributed on an "AS IS" BASIS,
0011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0012 // See the License for the specific language governing permissions and
0013 // limitations under the License.
0014 
0015 #ifndef ABSL_NUMERIC_INTERNAL_REPRESENTATION_H_
0016 #define ABSL_NUMERIC_INTERNAL_REPRESENTATION_H_
0017 
0018 #include <limits>
0019 
0020 #include "absl/base/config.h"
0021 
0022 namespace absl {
0023 ABSL_NAMESPACE_BEGIN
0024 namespace numeric_internal {
0025 
0026 // Returns true iff long double is represented as a pair of doubles added
0027 // together.
0028 inline constexpr bool IsDoubleDouble() {
0029   // A double-double value always has exactly twice the precision of a double
0030   // value--one double carries the high digits and one double carries the low
0031   // digits. This property is not shared with any other common floating-point
0032   // representation, so this test won't trigger false positives. For reference,
0033   // this table gives the number of bits of precision of each common
0034   // floating-point representation:
0035   //
0036   //                type     precision
0037   //         IEEE single          24 b
0038   //         IEEE double          53
0039   //     x86 long double          64
0040   //       double-double         106
0041   //      IEEE quadruple         113
0042   //
0043   // Note in particular that a quadruple-precision float has greater precision
0044   // than a double-double float despite taking up the same amount of memory; the
0045   // quad has more of its bits allocated to the mantissa than the double-double
0046   // has.
0047   return std::numeric_limits<long double>::digits ==
0048          2 * std::numeric_limits<double>::digits;
0049 }
0050 
0051 }  // namespace numeric_internal
0052 ABSL_NAMESPACE_END
0053 }  // namespace absl
0054 
0055 #endif  // ABSL_NUMERIC_INTERNAL_REPRESENTATION_H_