Skip to content

Commit

Permalink
FIX: float16ToPayload
Browse files Browse the repository at this point in the history
- 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!
  • Loading branch information
Waldemar Porscha committed Aug 22, 2023
1 parent 6dda682 commit 9c4e5d2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/knx/dptconvert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1749,8 +1749,8 @@ void float16ToPayload(uint8_t* payload, size_t payload_length, int index, double
value *= 100.0;
unsigned short exponent = 0;

if(value > 2048)
exponent = ceil(log2(value) - 11.0);
if(value >= 2048)
exponent = ceil(log2(value + 1.0) - 11.0);

short mantissa = roundf(value / (1 << exponent));

Expand Down

0 comments on commit 9c4e5d2

Please sign in to comment.