@@ -29,21 +29,6 @@ struct FloatTraits<T, 8 /*64bits*/> {
29
29
typedef int16_t exponent_type;
30
30
static const exponent_type exponent_max = 308 ;
31
31
32
- template <typename TExponent>
33
- static T make_float (T m, TExponent e) {
34
- auto powersOfTen =
35
- e > 0 ? positiveBinaryPowersOfTen () : negativeBinaryPowersOfTen ();
36
- if (e <= 0 )
37
- e = TExponent (-e);
38
-
39
- for (uint8_t index = 0 ; e != 0 ; index++) {
40
- if (e & 1 )
41
- m *= powersOfTen[index];
42
- e >>= 1 ;
43
- }
44
- return m;
45
- }
46
-
47
32
static pgm_ptr<T> positiveBinaryPowersOfTen () {
48
33
ARDUINOJSON_DEFINE_PROGMEM_ARRAY ( //
49
34
uint64_t , factors,
@@ -145,21 +130,6 @@ struct FloatTraits<T, 4 /*32bits*/> {
145
130
typedef int8_t exponent_type;
146
131
static const exponent_type exponent_max = 38 ;
147
132
148
- template <typename TExponent>
149
- static T make_float (T m, TExponent e) {
150
- auto powersOfTen =
151
- e > 0 ? positiveBinaryPowersOfTen () : negativeBinaryPowersOfTen ();
152
- if (e <= 0 )
153
- e = TExponent (-e);
154
-
155
- for (uint8_t index = 0 ; e != 0 ; index++) {
156
- if (e & 1 )
157
- m *= powersOfTen[index];
158
- e >>= 1 ;
159
- }
160
- return m;
161
- }
162
-
163
133
static pgm_ptr<T> positiveBinaryPowersOfTen () {
164
134
ARDUINOJSON_DEFINE_PROGMEM_ARRAY (uint32_t , factors,
165
135
{
@@ -252,4 +222,21 @@ struct FloatTraits<T, 4 /*32bits*/> {
252
222
}
253
223
};
254
224
225
+ template <typename TFloat, typename TExponent>
226
+ inline TFloat make_float (TFloat m, TExponent e) {
227
+ using traits = FloatTraits<TFloat>;
228
+
229
+ auto powersOfTen = e > 0 ? traits::positiveBinaryPowersOfTen ()
230
+ : traits::negativeBinaryPowersOfTen ();
231
+ if (e <= 0 )
232
+ e = TExponent (-e);
233
+
234
+ for (uint8_t index = 0 ; e != 0 ; index++) {
235
+ if (e & 1 )
236
+ m *= powersOfTen[index];
237
+ e >>= 1 ;
238
+ }
239
+ return m;
240
+ }
241
+
255
242
ARDUINOJSON_END_PRIVATE_NAMESPACE
0 commit comments