@@ -34,21 +34,21 @@ struct FloatTraits<T, 8 /*64bits*/> {
34
34
if (e > 0 ) {
35
35
for (uint8_t index = 0 ; e != 0 ; index++) {
36
36
if (e & 1 )
37
- m *= positiveBinaryPowerOfTen (index) ;
37
+ m *= positiveBinaryPowersOfTen ()[index] ;
38
38
e >>= 1 ;
39
39
}
40
40
} else {
41
41
e = TExponent (-e);
42
42
for (uint8_t index = 0 ; e != 0 ; index++) {
43
43
if (e & 1 )
44
- m *= negativeBinaryPowerOfTen (index) ;
44
+ m *= negativeBinaryPowersOfTen ()[index] ;
45
45
e >>= 1 ;
46
46
}
47
47
}
48
48
return m;
49
49
}
50
50
51
- static T positiveBinaryPowerOfTen ( int index ) {
51
+ static pgm_ptr<T> positiveBinaryPowersOfTen ( ) {
52
52
ARDUINOJSON_DEFINE_PROGMEM_ARRAY ( //
53
53
uint64_t , factors,
54
54
{
@@ -62,10 +62,10 @@ struct FloatTraits<T, 8 /*64bits*/> {
62
62
0x5A827748F9301D32 , // 1e128
63
63
0x75154FDD7F73BF3C , // 1e256
64
64
});
65
- return forge ( pgm_read (factors + index ));
65
+ return pgm_ptr<T>( reinterpret_cast < const T*> (factors));
66
66
}
67
67
68
- static T negativeBinaryPowerOfTen ( int index ) {
68
+ static pgm_ptr<T> negativeBinaryPowersOfTen ( ) {
69
69
ARDUINOJSON_DEFINE_PROGMEM_ARRAY ( //
70
70
uint64_t , factors,
71
71
{
@@ -79,10 +79,10 @@ struct FloatTraits<T, 8 /*64bits*/> {
79
79
0x255BBA08CF8C979D , // 1e-128
80
80
0x0AC8062864AC6F43 // 1e-256
81
81
});
82
- return forge ( pgm_read (factors + index ));
82
+ return pgm_ptr<T>( reinterpret_cast < const T*> (factors));
83
83
}
84
84
85
- static T negativeBinaryPowerOfTenPlusOne ( int index ) {
85
+ static pgm_ptr<T> negativeBinaryPowersOfTenPlusOne ( ) {
86
86
ARDUINOJSON_DEFINE_PROGMEM_ARRAY ( //
87
87
uint64_t , factors,
88
88
{
@@ -96,7 +96,7 @@ struct FloatTraits<T, 8 /*64bits*/> {
96
96
0x2591544581B7DEC2 , // 1e-127
97
97
0x0AFE07B27DD78B14 // 1e-255
98
98
});
99
- return forge ( pgm_read (factors + index ));
99
+ return pgm_ptr<T>( reinterpret_cast < const T*> (factors));
100
100
}
101
101
102
102
static T nan () {
@@ -154,21 +154,21 @@ struct FloatTraits<T, 4 /*32bits*/> {
154
154
if (e > 0 ) {
155
155
for (uint8_t index = 0 ; e != 0 ; index++) {
156
156
if (e & 1 )
157
- m *= positiveBinaryPowerOfTen (index) ;
157
+ m *= positiveBinaryPowersOfTen ()[index] ;
158
158
e >>= 1 ;
159
159
}
160
160
} else {
161
161
e = -e;
162
162
for (uint8_t index = 0 ; e != 0 ; index++) {
163
163
if (e & 1 )
164
- m *= negativeBinaryPowerOfTen (index) ;
164
+ m *= negativeBinaryPowersOfTen ()[index] ;
165
165
e >>= 1 ;
166
166
}
167
167
}
168
168
return m;
169
169
}
170
170
171
- static T positiveBinaryPowerOfTen ( int index ) {
171
+ static pgm_ptr<T> positiveBinaryPowersOfTen ( ) {
172
172
ARDUINOJSON_DEFINE_PROGMEM_ARRAY (uint32_t , factors,
173
173
{
174
174
0x41200000 , // 1e1f
@@ -178,10 +178,10 @@ struct FloatTraits<T, 4 /*32bits*/> {
178
178
0x5a0e1bca , // 1e16f
179
179
0x749dc5ae // 1e32f
180
180
});
181
- return forge ( pgm_read (factors + index ));
181
+ return pgm_ptr<T>( reinterpret_cast < const T*> (factors));
182
182
}
183
183
184
- static T negativeBinaryPowerOfTen ( int index ) {
184
+ static pgm_ptr<T> negativeBinaryPowersOfTen ( ) {
185
185
ARDUINOJSON_DEFINE_PROGMEM_ARRAY (uint32_t , factors,
186
186
{
187
187
0x3dcccccd , // 1e-1f
@@ -191,10 +191,10 @@ struct FloatTraits<T, 4 /*32bits*/> {
191
191
0x24e69595 , // 1e-16f
192
192
0x0a4fb11f // 1e-32f
193
193
});
194
- return forge ( pgm_read (factors + index ));
194
+ return pgm_ptr<T>( reinterpret_cast < const T*> (factors));
195
195
}
196
196
197
- static T negativeBinaryPowerOfTenPlusOne ( int index ) {
197
+ static pgm_ptr<T> negativeBinaryPowersOfTenPlusOne ( ) {
198
198
ARDUINOJSON_DEFINE_PROGMEM_ARRAY (uint32_t , factors,
199
199
{
200
200
0x3f800000 , // 1e0f
@@ -204,7 +204,7 @@ struct FloatTraits<T, 4 /*32bits*/> {
204
204
0x26901d7d , // 1e-15f
205
205
0x0c01ceb3 // 1e-31f
206
206
});
207
- return forge ( pgm_read (factors + index ));
207
+ return pgm_ptr<T>( reinterpret_cast < const T*> (factors));
208
208
}
209
209
210
210
static T forge (uint32_t bits) {
0 commit comments