// Copyright 2018 The Abseil Authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "absl/strings/internal/pow10_helper.h" #include <cmath> namespace absl { ABSL_NAMESPACE_BEGIN namespace strings_internal { namespace { // The exact value of 1e23 falls precisely halfway between two representable // doubles. Furthermore, the rounding rules we prefer (break ties by rounding // to the nearest even) dictate in this case that the number should be rounded // down, but this is not completely specified for floating-point literals in // C++. (It just says to use the default rounding mode of the standard // library.) We ensure the result we want by using a number that has an // unambiguous correctly rounded answer. constexpr double k1e23 = …; constexpr double kPowersOfTen[] = …; } // namespace double Pow10(int exp) { … } } // namespace strings_internal ABSL_NAMESPACE_END } // namespace absl