@@ -22,17 +22,17 @@ namespace fast_float {
22
22
namespace detail {
23
23
24
24
// remove all final zeroes
25
- inline void trim (decimal &h) {
25
+ CXX20_CONSTEXPR inline void trim (decimal &h) {
26
26
while ((h.num_digits > 0 ) && (h.digits [h.num_digits - 1 ] == 0 )) {
27
27
h.num_digits --;
28
28
}
29
29
}
30
30
31
31
32
32
33
- inline uint32_t number_of_digits_decimal_left_shift (const decimal &h, uint32_t shift) {
33
+ CXX20_CONSTEXPR inline uint32_t number_of_digits_decimal_left_shift (const decimal &h, uint32_t shift) {
34
34
shift &= 63 ;
35
- const static uint16_t number_of_digits_decimal_left_shift_table[65 ] = {
35
+ constexpr uint16_t number_of_digits_decimal_left_shift_table[65 ] = {
36
36
0x0000 , 0x0800 , 0x0801 , 0x0803 , 0x1006 , 0x1009 , 0x100D , 0x1812 , 0x1817 ,
37
37
0x181D , 0x2024 , 0x202B , 0x2033 , 0x203C , 0x2846 , 0x2850 , 0x285B , 0x3067 ,
38
38
0x3073 , 0x3080 , 0x388E , 0x389C , 0x38AB , 0x38BB , 0x40CC , 0x40DD , 0x40EF ,
@@ -47,7 +47,7 @@ inline uint32_t number_of_digits_decimal_left_shift(const decimal &h, uint32_t s
47
47
uint32_t num_new_digits = x_a >> 11 ;
48
48
uint32_t pow5_a = 0x7FF & x_a;
49
49
uint32_t pow5_b = 0x7FF & x_b;
50
- const static uint8_t
50
+ constexpr uint8_t
51
51
number_of_digits_decimal_left_shift_table_powers_of_5[0x051C ] = {
52
52
5 , 2 , 5 , 1 , 2 , 5 , 6 , 2 , 5 , 3 , 1 , 2 , 5 , 1 , 5 , 6 , 2 , 5 , 7 , 8 , 1 , 2 , 5 , 3 ,
53
53
9 , 0 , 6 , 2 , 5 , 1 , 9 , 5 , 3 , 1 , 2 , 5 , 9 , 7 , 6 , 5 , 6 , 2 , 5 , 4 , 8 , 8 , 2 , 8 ,
@@ -123,7 +123,7 @@ inline uint32_t number_of_digits_decimal_left_shift(const decimal &h, uint32_t s
123
123
return num_new_digits;
124
124
}
125
125
126
- inline uint64_t round (decimal &h) {
126
+ CXX20_CONSTEXPR inline uint64_t round (decimal &h) {
127
127
if ((h.num_digits == 0 ) || (h.decimal_point < 0 )) {
128
128
return 0 ;
129
129
} else if (h.decimal_point > 18 ) {
@@ -150,7 +150,7 @@ inline uint64_t round(decimal &h) {
150
150
}
151
151
152
152
// computes h * 2^-shift
153
- inline void decimal_left_shift (decimal &h, uint32_t shift) {
153
+ CXX20_CONSTEXPR inline void decimal_left_shift (decimal &h, uint32_t shift) {
154
154
if (h.num_digits == 0 ) {
155
155
return ;
156
156
}
@@ -192,7 +192,7 @@ inline void decimal_left_shift(decimal &h, uint32_t shift) {
192
192
}
193
193
194
194
// computes h * 2^shift
195
- inline void decimal_right_shift (decimal &h, uint32_t shift) {
195
+ CXX20_CONSTEXPR inline void decimal_right_shift (decimal &h, uint32_t shift) {
196
196
uint32_t read_index = 0 ;
197
197
uint32_t write_index = 0 ;
198
198
@@ -241,7 +241,7 @@ inline void decimal_right_shift(decimal &h, uint32_t shift) {
241
241
} // namespace detail
242
242
243
243
template <typename binary>
244
- adjusted_mantissa compute_float (decimal &d) {
244
+ CXX20_CONSTEXPR adjusted_mantissa compute_float (decimal &d) {
245
245
adjusted_mantissa answer;
246
246
if (d.num_digits == 0 ) {
247
247
// should be zero
@@ -271,9 +271,9 @@ adjusted_mantissa compute_float(decimal &d) {
271
271
answer.mantissa = 0 ;
272
272
return answer;
273
273
}
274
- static const uint32_t max_shift = 60 ;
275
- static const uint32_t num_powers = 19 ;
276
- static const uint8_t decimal_powers[19 ] = {
274
+ constexpr uint32_t max_shift = 60 ;
275
+ constexpr uint32_t num_powers = 19 ;
276
+ constexpr uint8_t decimal_powers[19 ] = {
277
277
0 , 3 , 6 , 9 , 13 , 16 , 19 , 23 , 26 , 29 , //
278
278
33 , 36 , 39 , 43 , 46 , 49 , 53 , 56 , 59 , //
279
279
};
@@ -351,7 +351,7 @@ adjusted_mantissa compute_float(decimal &d) {
351
351
}
352
352
353
353
template <typename binary>
354
- adjusted_mantissa parse_long_mantissa (const char *first, const char * last, parse_options options) {
354
+ CXX20_CONSTEXPR adjusted_mantissa parse_long_mantissa (const char *first, const char * last, parse_options options) {
355
355
decimal d = parse_decimal (first, last, options);
356
356
return compute_float<binary>(d);
357
357
}
0 commit comments