xref: /freebsd/contrib/llvm-project/libcxx/src/include/ryu/digit_table.h (revision 04eeddc0aa8e0a417a16eaf9d7d095207f4a8623)
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // Copyright (c) Microsoft Corporation.
10 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11 
12 // Copyright 2018 Ulf Adams
13 // Copyright (c) Microsoft Corporation. All rights reserved.
14 
15 // Boost Software License - Version 1.0 - August 17th, 2003
16 
17 // Permission is hereby granted, free of charge, to any person or organization
18 // obtaining a copy of the software and accompanying documentation covered by
19 // this license (the "Software") to use, reproduce, display, distribute,
20 // execute, and transmit the Software, and to prepare derivative works of the
21 // Software, and to permit third-parties to whom the Software is furnished to
22 // do so, all subject to the following:
23 
24 // The copyright notices in the Software and this entire statement, including
25 // the above license grant, this restriction and the following disclaimer,
26 // must be included in all copies of the Software, in whole or in part, and
27 // all derivative works of the Software, unless such copies or derivative
28 // works are solely in the form of machine-executable object code generated by
29 // a source language processor.
30 
31 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
34 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
35 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
36 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
37 // DEALINGS IN THE SOFTWARE.
38 
39 #ifndef _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H
40 #define _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H
41 
42 // Avoid formatting to keep the changes with the original code minimal.
43 // clang-format off
44 
45 #include "__config"
46 
47 _LIBCPP_BEGIN_NAMESPACE_STD
48 
49 // A table of all two-digit numbers. This is used to speed up decimal digit
50 // generation by copying pairs of digits into the final output.
51 inline constexpr char __DIGIT_TABLE[200] = {
52   '0','0','0','1','0','2','0','3','0','4','0','5','0','6','0','7','0','8','0','9',
53   '1','0','1','1','1','2','1','3','1','4','1','5','1','6','1','7','1','8','1','9',
54   '2','0','2','1','2','2','2','3','2','4','2','5','2','6','2','7','2','8','2','9',
55   '3','0','3','1','3','2','3','3','3','4','3','5','3','6','3','7','3','8','3','9',
56   '4','0','4','1','4','2','4','3','4','4','4','5','4','6','4','7','4','8','4','9',
57   '5','0','5','1','5','2','5','3','5','4','5','5','5','6','5','7','5','8','5','9',
58   '6','0','6','1','6','2','6','3','6','4','6','5','6','6','6','7','6','8','6','9',
59   '7','0','7','1','7','2','7','3','7','4','7','5','7','6','7','7','7','8','7','9',
60   '8','0','8','1','8','2','8','3','8','4','8','5','8','6','8','7','8','8','8','9',
61   '9','0','9','1','9','2','9','3','9','4','9','5','9','6','9','7','9','8','9','9'
62 };
63 
64 _LIBCPP_END_NAMESPACE_STD
65 
66 // clang-format on
67 
68 #endif // _LIBCPP_SRC_INCLUDE_RYU_DIGIT_TABLE_H
69