mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Reduce size of make_float()
				
					
				
			This commit is contained in:
		| @@ -31,19 +31,15 @@ struct FloatTraits<T, 8 /*64bits*/> { | |||||||
|  |  | ||||||
|   template <typename TExponent> |   template <typename TExponent> | ||||||
|   static T make_float(T m, TExponent e) { |   static T make_float(T m, TExponent e) { | ||||||
|     if (e > 0) { |     auto powersOfTen = | ||||||
|       for (uint8_t index = 0; e != 0; index++) { |         e > 0 ? positiveBinaryPowersOfTen() : negativeBinaryPowersOfTen(); | ||||||
|         if (e & 1) |     if (e <= 0) | ||||||
|           m *= positiveBinaryPowersOfTen()[index]; |  | ||||||
|         e >>= 1; |  | ||||||
|       } |  | ||||||
|     } else { |  | ||||||
|       e = TExponent(-e); |       e = TExponent(-e); | ||||||
|       for (uint8_t index = 0; e != 0; index++) { |  | ||||||
|         if (e & 1) |     for (uint8_t index = 0; e != 0; index++) { | ||||||
|           m *= negativeBinaryPowersOfTen()[index]; |       if (e & 1) | ||||||
|         e >>= 1; |         m *= powersOfTen[index]; | ||||||
|       } |       e >>= 1; | ||||||
|     } |     } | ||||||
|     return m; |     return m; | ||||||
|   } |   } | ||||||
| @@ -151,19 +147,15 @@ struct FloatTraits<T, 4 /*32bits*/> { | |||||||
|  |  | ||||||
|   template <typename TExponent> |   template <typename TExponent> | ||||||
|   static T make_float(T m, TExponent e) { |   static T make_float(T m, TExponent e) { | ||||||
|     if (e > 0) { |     auto powersOfTen = | ||||||
|       for (uint8_t index = 0; e != 0; index++) { |         e > 0 ? positiveBinaryPowersOfTen() : negativeBinaryPowersOfTen(); | ||||||
|         if (e & 1) |     if (e <= 0) | ||||||
|           m *= positiveBinaryPowersOfTen()[index]; |       e = TExponent(-e); | ||||||
|         e >>= 1; |  | ||||||
|       } |     for (uint8_t index = 0; e != 0; index++) { | ||||||
|     } else { |       if (e & 1) | ||||||
|       e = -e; |         m *= powersOfTen[index]; | ||||||
|       for (uint8_t index = 0; e != 0; index++) { |       e >>= 1; | ||||||
|         if (e & 1) |  | ||||||
|           m *= negativeBinaryPowersOfTen()[index]; |  | ||||||
|         e >>= 1; |  | ||||||
|       } |  | ||||||
|     } |     } | ||||||
|     return m; |     return m; | ||||||
|   } |   } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user