mirror of
				https://github.com/thelsing/knx.git
				synced 2025-10-26 10:26:25 +01:00 
			
		
		
		
	Improved float16ToPayload correction
This commit is contained in:
		
							parent
							
								
									9c4e5d259a
								
							
						
					
					
						commit
						a5c79214e3
					
				| @ -1753,6 +1753,12 @@ void float16ToPayload(uint8_t* payload, size_t payload_length, int index, double | ||||
|         exponent = ceil(log2(value + 1.0) - 11.0); | ||||
|      | ||||
|     short mantissa = roundf(value / (1 << exponent)); | ||||
|     // above calculation causes mantissa overflow for values of the form 2^n, where n>11
 | ||||
|     if (mantissa >= 0x800) | ||||
|     { | ||||
|         exponent++; | ||||
|         mantissa = roundf(value / (1 << exponent)); | ||||
|     } | ||||
| 
 | ||||
|     if (wasNegative) | ||||
|         mantissa *= -1; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user