File tree Expand file tree Collapse file tree 1 file changed +20
-21
lines changed
fixed_lib/include/fixedmath Expand file tree Collapse file tree 1 file changed +20
-21
lines changed Original file line number Diff line number Diff line change 11
11
#include < optional>
12
12
#include < algorithm>
13
13
#include < concepts>
14
+ #include < array>
14
15
#include " detail/static_call_operator_prolog.h"
15
16
16
17
namespace fixedmath ::inline v2
@@ -69,25 +70,23 @@ namespace detail
69
70
70
71
inline constexpr isdigit_t isdigit;
71
72
72
- namespace string
73
- {
74
- constexpr fixed_internal power[14 ]{
75
- 28147497671066 ,
76
- 2814749767107 ,
77
- 281474976711 ,
78
- 28147497671 ,
79
- 2814749767 ,
80
- 281474977 ,
81
- 28147498 ,
82
- 2814750 ,
83
- 281475 ,
84
- 28148 ,
85
- 2815 ,
86
- 281 ,
87
- 28 ,
88
- 3
89
- }; // 10^-1 * 2^16 (rounded down)
90
- }
73
+ // 10^-1 * 2^16 (rounded down)
74
+ inline constexpr std::array<fixed_internal, 14 > from_string_powers{
75
+ 28147497671066 ,
76
+ 2814749767107 ,
77
+ 281474976711 ,
78
+ 28147497671 ,
79
+ 2814749767 ,
80
+ 281474977 ,
81
+ 28147498 ,
82
+ 2814750 ,
83
+ 281475 ,
84
+ 28148 ,
85
+ 2815 ,
86
+ 281 ,
87
+ 28 ,
88
+ 3
89
+ };
91
90
92
91
} // namespace detail
93
92
@@ -174,10 +173,10 @@ namespace func
174
173
int digit{str[pos] - ' 0' };
175
174
176
175
// Add digit * current power of 10
177
- fraction += digit * detail::string::power [i];
176
+ fraction += digit * detail::from_string_powers [i];
178
177
179
178
// Next decimal place (divide by 10)
180
- if (i == sizeof ( detail::string::power) / sizeof (fixed_internal ) - 1 ) // Stop if we've reached our precision limit
179
+ if (i == detail::from_string_powers. size ( ) - 1 ) // Stop if we've reached our precision limit
181
180
break ;
182
181
183
182
++pos;
You can’t perform that action at this time.
0 commit comments