FIX: float16ToPayload

- all DPT9 numbers of the form (2^n)/100, n>10 (first value is 20.48) were converted to a payload of 0
- in other words: 20.48; 40.96; 81.92; etc. were send as 0!
This commit is contained in:
Waldemar Porscha 2023-08-22 11:28:10 +02:00
parent 6dda682fa7
commit 9c4e5d259a

View File

@ -1749,8 +1749,8 @@ void float16ToPayload(uint8_t* payload, size_t payload_length, int index, double
value *= 100.0; value *= 100.0;
unsigned short exponent = 0; unsigned short exponent = 0;
if(value > 2048) if(value >= 2048)
exponent = ceil(log2(value) - 11.0); exponent = ceil(log2(value + 1.0) - 11.0);
short mantissa = roundf(value / (1 << exponent)); short mantissa = roundf(value / (1 << exponent));