// 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/charconv_bigint.h" #include <algorithm> #include <cassert> #include <string> namespace absl { ABSL_NAMESPACE_BEGIN namespace strings_internal { namespace { // Table containing some large powers of 5, for fast computation. // Constant step size for entries in the kLargePowersOfFive table. Each entry // is larger than the previous entry by a factor of 5**kLargePowerOfFiveStep // (or 5**27). // // In other words, the Nth entry in the table is 5**(27*N). // // 5**27 is the largest power of 5 that fits in 64 bits. constexpr int kLargePowerOfFiveStep = …; // The largest legal index into the kLargePowersOfFive table. // // In other words, the largest precomputed power of 5 is 5**(27*20). constexpr int kLargestPowerOfFiveIndex = …; // Table of powers of (5**27), up to (5**27)**20 == 5**540. // // Used to generate large powers of 5 while limiting the number of repeated // multiplications required. // // clang-format off const uint32_t kLargePowersOfFive[] = …; // clang-format on // Returns a pointer to the big integer data for (5**27)**i. i must be // between 1 and 20, inclusive. const uint32_t* LargePowerOfFiveData(int i) { … } // Returns the size of the big integer data for (5**27)**i, in words. i must be // between 1 and 20, inclusive. int LargePowerOfFiveSize(int i) { … } } // namespace ABSL_DLL const uint32_t kFiveToNth[14] = …; ABSL_DLL const uint32_t kTenToNth[10] = …; template <int max_words> int BigUnsigned<max_words>::ReadFloatMantissa(const ParsedFloat& fp, int significant_digits) { … } template <int max_words> int BigUnsigned<max_words>::ReadDigits(const char* begin, const char* end, int significant_digits) { … } template <int max_words> /* static */ BigUnsigned<max_words> BigUnsigned<max_words>::FiveToTheNth( int n) { … } template <int max_words> void BigUnsigned<max_words>::MultiplyStep(int original_size, const uint32_t* other_words, int other_size, int step) { … } template <int max_words> std::string BigUnsigned<max_words>::ToString() const { … } template class BigUnsigned<4>; template class BigUnsigned<84>; } // namespace strings_internal ABSL_NAMESPACE_END } // namespace absl