Path: blob/main/contrib/llvm-project/libcxx/include/__charconv/tables.h
35262 views
// -*- C++ -*-1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//89#ifndef _LIBCPP___CHARCONV_TABLES10#define _LIBCPP___CHARCONV_TABLES1112#include <__config>13#include <cstdint>1415#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)16# pragma GCC system_header17#endif1819_LIBCPP_BEGIN_NAMESPACE_STD2021#if _LIBCPP_STD_VER >= 172223namespace __itoa {2425inline constexpr char __base_2_lut[64] = {26'0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '1', '0', '0', '0', '1', '1', '0', '1', '0', '0', '0', '1',27'0', '1', '0', '1', '1', '0', '0', '1', '1', '1', '1', '0', '0', '0', '1', '0', '0', '1', '1', '0', '1', '0',28'1', '0', '1', '1', '1', '1', '0', '0', '1', '1', '0', '1', '1', '1', '1', '0', '1', '1', '1', '1'};2930inline constexpr char __base_8_lut[128] = {31'0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '1', '0', '1', '1', '1', '2',32'1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5',33'2', '6', '2', '7', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '4', '0',34'4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '5', '0', '5', '1', '5', '2', '5', '3',35'5', '4', '5', '5', '5', '6', '5', '7', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6',36'6', '7', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7'};3738inline constexpr char __base_16_lut[512] = {39'0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9', '0', 'a', '0',40'b', '0', 'c', '0', 'd', '0', 'e', '0', 'f', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6',41'1', '7', '1', '8', '1', '9', '1', 'a', '1', 'b', '1', 'c', '1', 'd', '1', 'e', '1', 'f', '2', '0', '2', '1', '2',42'2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9', '2', 'a', '2', 'b', '2', 'c', '2', 'd',43'2', 'e', '2', 'f', '3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3',44'9', '3', 'a', '3', 'b', '3', 'c', '3', 'd', '3', 'e', '3', 'f', '4', '0', '4', '1', '4', '2', '4', '3', '4', '4',45'4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '4', 'a', '4', 'b', '4', 'c', '4', 'd', '4', 'e', '4', 'f', '5',46'0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9', '5', 'a', '5', 'b',47'5', 'c', '5', 'd', '5', 'e', '5', 'f', '6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6',48'7', '6', '8', '6', '9', '6', 'a', '6', 'b', '6', 'c', '6', 'd', '6', 'e', '6', 'f', '7', '0', '7', '1', '7', '2',49'7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9', '7', 'a', '7', 'b', '7', 'c', '7', 'd', '7',50'e', '7', 'f', '8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9',51'8', 'a', '8', 'b', '8', 'c', '8', 'd', '8', 'e', '8', 'f', '9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9',52'5', '9', '6', '9', '7', '9', '8', '9', '9', '9', 'a', '9', 'b', '9', 'c', '9', 'd', '9', 'e', '9', 'f', 'a', '0',53'a', '1', 'a', '2', 'a', '3', 'a', '4', 'a', '5', 'a', '6', 'a', '7', 'a', '8', 'a', '9', 'a', 'a', 'a', 'b', 'a',54'c', 'a', 'd', 'a', 'e', 'a', 'f', 'b', '0', 'b', '1', 'b', '2', 'b', '3', 'b', '4', 'b', '5', 'b', '6', 'b', '7',55'b', '8', 'b', '9', 'b', 'a', 'b', 'b', 'b', 'c', 'b', 'd', 'b', 'e', 'b', 'f', 'c', '0', 'c', '1', 'c', '2', 'c',56'3', 'c', '4', 'c', '5', 'c', '6', 'c', '7', 'c', '8', 'c', '9', 'c', 'a', 'c', 'b', 'c', 'c', 'c', 'd', 'c', 'e',57'c', 'f', 'd', '0', 'd', '1', 'd', '2', 'd', '3', 'd', '4', 'd', '5', 'd', '6', 'd', '7', 'd', '8', 'd', '9', 'd',58'a', 'd', 'b', 'd', 'c', 'd', 'd', 'd', 'e', 'd', 'f', 'e', '0', 'e', '1', 'e', '2', 'e', '3', 'e', '4', 'e', '5',59'e', '6', 'e', '7', 'e', '8', 'e', '9', 'e', 'a', 'e', 'b', 'e', 'c', 'e', 'd', 'e', 'e', 'e', 'f', 'f', '0', 'f',60'1', 'f', '2', 'f', '3', 'f', '4', 'f', '5', 'f', '6', 'f', '7', 'f', '8', 'f', '9', 'f', 'a', 'f', 'b', 'f', 'c',61'f', 'd', 'f', 'e', 'f', 'f'};6263inline constexpr uint32_t __pow10_32[10] = {64UINT32_C(0),65UINT32_C(10),66UINT32_C(100),67UINT32_C(1000),68UINT32_C(10000),69UINT32_C(100000),70UINT32_C(1000000),71UINT32_C(10000000),72UINT32_C(100000000),73UINT32_C(1000000000)};7475inline constexpr uint64_t __pow10_64[20] = {76UINT64_C(0),77UINT64_C(10),78UINT64_C(100),79UINT64_C(1000),80UINT64_C(10000),81UINT64_C(100000),82UINT64_C(1000000),83UINT64_C(10000000),84UINT64_C(100000000),85UINT64_C(1000000000),86UINT64_C(10000000000),87UINT64_C(100000000000),88UINT64_C(1000000000000),89UINT64_C(10000000000000),90UINT64_C(100000000000000),91UINT64_C(1000000000000000),92UINT64_C(10000000000000000),93UINT64_C(100000000000000000),94UINT64_C(1000000000000000000),95UINT64_C(10000000000000000000)};9697# ifndef _LIBCPP_HAS_NO_INT12898inline constexpr int __pow10_128_offset = 0;99inline constexpr __uint128_t __pow10_128[40] = {100UINT64_C(0),101UINT64_C(10),102UINT64_C(100),103UINT64_C(1000),104UINT64_C(10000),105UINT64_C(100000),106UINT64_C(1000000),107UINT64_C(10000000),108UINT64_C(100000000),109UINT64_C(1000000000),110UINT64_C(10000000000),111UINT64_C(100000000000),112UINT64_C(1000000000000),113UINT64_C(10000000000000),114UINT64_C(100000000000000),115UINT64_C(1000000000000000),116UINT64_C(10000000000000000),117UINT64_C(100000000000000000),118UINT64_C(1000000000000000000),119UINT64_C(10000000000000000000),120__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10),121__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100),122__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000),123__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000),124__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000),125__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000),126__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000),127__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000),128__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000),129__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000),130__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000),131__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000),132__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000),133__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000000),134__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000000),135__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000),136__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(100000000000000000),137__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(1000000000000000000),138__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000),139(__uint128_t(UINT64_C(10000000000000000000)) * UINT64_C(10000000000000000000)) * 10};140# endif141142inline constexpr char __digits_base_10[200] = {143// clang-format off144'0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0', '7', '0', '8', '0', '9',145'1', '0', '1', '1', '1', '2', '1', '3', '1', '4', '1', '5', '1', '6', '1', '7', '1', '8', '1', '9',146'2', '0', '2', '1', '2', '2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9',147'3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3', '7', '3', '8', '3', '9',148'4', '0', '4', '1', '4', '2', '4', '3', '4', '4', '4', '5', '4', '6', '4', '7', '4', '8', '4', '9',149'5', '0', '5', '1', '5', '2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9',150'6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6', '7', '6', '8', '6', '9',151'7', '0', '7', '1', '7', '2', '7', '3', '7', '4', '7', '5', '7', '6', '7', '7', '7', '8', '7', '9',152'8', '0', '8', '1', '8', '2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9',153'9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9', '7', '9', '8', '9', '9'};154// clang-format on155156} // namespace __itoa157158#endif // _LIBCPP_STD_VER >= 17159160_LIBCPP_END_NAMESPACE_STD161162#endif // _LIBCPP___CHARCONV_TABLES163164165