@@ -22,17 +22,17 @@ namespace fast_float {
2222namespace detail {
2323
2424// remove all final zeroes
25- inline void trim (decimal &h) {
25+ CXX20_CONSTEXPR inline void trim (decimal &h) {
2626 while ((h.num_digits > 0 ) && (h.digits [h.num_digits - 1 ] == 0 )) {
2727 h.num_digits --;
2828 }
2929}
3030
3131
3232
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) {
3434 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 ] = {
3636 0x0000 , 0x0800 , 0x0801 , 0x0803 , 0x1006 , 0x1009 , 0x100D , 0x1812 , 0x1817 ,
3737 0x181D , 0x2024 , 0x202B , 0x2033 , 0x203C , 0x2846 , 0x2850 , 0x285B , 0x3067 ,
3838 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
4747 uint32_t num_new_digits = x_a >> 11 ;
4848 uint32_t pow5_a = 0x7FF & x_a;
4949 uint32_t pow5_b = 0x7FF & x_b;
50- const static uint8_t
50+ constexpr uint8_t
5151 number_of_digits_decimal_left_shift_table_powers_of_5[0x051C ] = {
5252 5 , 2 , 5 , 1 , 2 , 5 , 6 , 2 , 5 , 3 , 1 , 2 , 5 , 1 , 5 , 6 , 2 , 5 , 7 , 8 , 1 , 2 , 5 , 3 ,
5353 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
123123 return num_new_digits;
124124}
125125
126- inline uint64_t round (decimal &h) {
126+ CXX20_CONSTEXPR inline uint64_t round (decimal &h) {
127127 if ((h.num_digits == 0 ) || (h.decimal_point < 0 )) {
128128 return 0 ;
129129 } else if (h.decimal_point > 18 ) {
@@ -150,7 +150,7 @@ inline uint64_t round(decimal &h) {
150150}
151151
152152// 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) {
154154 if (h.num_digits == 0 ) {
155155 return ;
156156 }
@@ -192,7 +192,7 @@ inline void decimal_left_shift(decimal &h, uint32_t shift) {
192192}
193193
194194// 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) {
196196 uint32_t read_index = 0 ;
197197 uint32_t write_index = 0 ;
198198
@@ -241,7 +241,7 @@ inline void decimal_right_shift(decimal &h, uint32_t shift) {
241241} // namespace detail
242242
243243template <typename binary>
244- adjusted_mantissa compute_float (decimal &d) {
244+ CXX20_CONSTEXPR adjusted_mantissa compute_float (decimal &d) {
245245 adjusted_mantissa answer;
246246 if (d.num_digits == 0 ) {
247247 // should be zero
@@ -271,9 +271,9 @@ adjusted_mantissa compute_float(decimal &d) {
271271 answer.mantissa = 0 ;
272272 return answer;
273273 }
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 ] = {
277277 0 , 3 , 6 , 9 , 13 , 16 , 19 , 23 , 26 , 29 , //
278278 33 , 36 , 39 , 43 , 46 , 49 , 53 , 56 , 59 , //
279279 };
@@ -351,7 +351,7 @@ adjusted_mantissa compute_float(decimal &d) {
351351}
352352
353353template <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) {
355355 decimal d = parse_decimal (first, last, options);
356356 return compute_float<binary>(d);
357357}
0 commit comments