Two's complement

From OpenMotics
Revision as of 13:32, 25 October 2020 by Wilbert (talk | contribs)
Jump to navigation Jump to search

Values like offset are being written in Two's complement notation. This means that, when using Basic Action, a byte value (0-255) can also represent a negative value.

Byte value is converted in Two's complement:

Byte Value Two's complement
128 -128
... ...
251 -5
252 -4
253 -3
254 -2
255 -1
0 0
1 +1
2 +2
3 +3
4 +4
5 +5
... ...
127 +127

Example: We want to program an offset of -2,5°C for sensor2 so the actual measured temperature will be displayed as follows: Display value sensor2=measured value(in °C) + (- 2,5°C). If we want to convert this to a Basic Action, we know that system values work in 0.5°C so we need to program -5. Following CLI instruction will program an offset -2,5°C for sensor 2: "basic action activate 7 2 0 250 0 0"