pow10_helper.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // Copyright 2018 The Abseil Authors.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // https://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. // This test helper library contains a table of powers of 10, to guarantee
  17. // precise values are computed across the full range of doubles. We can't rely
  18. // on the pow() function, because not all standard libraries ship a version
  19. // that is precise.
  20. #ifndef ABSL_STRINGS_INTERNAL_POW10_HELPER_H_
  21. #define ABSL_STRINGS_INTERNAL_POW10_HELPER_H_
  22. #include <vector>
  23. #include "absl/base/config.h"
  24. namespace absl {
  25. ABSL_NAMESPACE_BEGIN
  26. namespace strings_internal {
  27. // Computes the precise value of 10^exp. (I.e. the nearest representable
  28. // double to the exact value, rounding to nearest-even in the (single) case of
  29. // being exactly halfway between.)
  30. double Pow10(int exp);
  31. } // namespace strings_internal
  32. ABSL_NAMESPACE_END
  33. } // namespace absl
  34. #endif // ABSL_STRINGS_INTERNAL_POW10_HELPER_H_