1#ifndef SIMDJSON_INTERNAL_NUMBERPARSING_TABLES_H
2#define SIMDJSON_INTERNAL_NUMBERPARSING_TABLES_H
3
4#include "simdjson/base.h"
5
6namespace simdjson {
7namespace internal {
8/**
9 * The smallest non-zero float (binary64) is 2^-1074.
10 * We take as input numbers of the form w x 10^q where w < 2^64.
11 * We have that w * 10^-343 < 2^(64-344) 5^-343 < 2^-1076.
12 * However, we have that
13 * (2^64-1) * 10^-342 = (2^64-1) * 2^-342 * 5^-342 > 2^-1074.
14 * Thus it is possible for a number of the form w * 10^-342 where
15 * w is a 64-bit value to be a non-zero floating-point number.
16 *********
17 * Any number of form w * 10^309 where w>= 1 is going to be
18 * infinite in binary64 so we never need to worry about powers
19 * of 5 greater than 308.
20 */
21constexpr int smallest_power = -342;
22constexpr int largest_power = 308;
23
24/**
25 * Represents a 128-bit value.
26 * low: least significant 64 bits.
27 * high: most significant 64 bits.
28 */
29struct value128 {
30 uint64_t low;
31 uint64_t high;
32};
33
34
35// Precomputed powers of ten from 10^0 to 10^22. These
36// can be represented exactly using the double type.
37extern SIMDJSON_DLLIMPORTEXPORT const double power_of_ten[];
38
39
40/**
41 * When mapping numbers from decimal to binary,
42 * we go from w * 10^q to m * 2^p but we have
43 * 10^q = 5^q * 2^q, so effectively
44 * we are trying to match
45 * w * 2^q * 5^q to m * 2^p. Thus the powers of two
46 * are not a concern since they can be represented
47 * exactly using the binary notation, only the powers of five
48 * affect the binary significand.
49 */
50
51
52// The truncated powers of five from 5^-342 all the way to 5^308
53// The mantissa is truncated to 128 bits, and
54// never rounded up. Uses about 10KB.
55extern SIMDJSON_DLLIMPORTEXPORT const uint64_t power_of_five_128[];
56} // namespace internal
57} // namespace simdjson
58
59#endif // SIMDJSON_INTERNAL_NUMBERPARSING_TABLES_H
60