English
Language : 

TN1180 Datasheet, PDF (2/9 Pages) STMicroelectronics – How to interpret pressure and temperature readings in pressure sensors
Why we use two's complement
TN1180
1
Why we use two's complement
Measuring analog values and storing the data in a digital domain creates an interesting
dilemma. How do we represent negative analog values in a digital system? How do we
handle the number zero?
A computing system uses two's complement to simplify the processing logic required to
handle negative numbers and subtractions. A circuit designed for addition can handle
negative operands by using two’s complement. This minimizes the need for additional
circuitry capable of subtraction or additional switching circuitry based on the sign. Most
modern computers, MCU’s, and DSP’s use two’s complement notation.
If a register is defined as two’s complement, typically the most significant bit (msb) of the
most significant byte (MSB) indicates the sign as shown in the figure below. If the msb of
the register is 1, the number is negative and we use two’s complement. If the bit is 0, the
integer is positive and no translation is necessary.
Figure 2: Sign bit indicates whether a value is positive or negative
PressOut_H (0x2A)
Bit Bit Bit Bit Bit Bit Bit Bit
23 22 21 20 19 18 17 16
S
I
G
N
0 = POS
1 = NEG
PressOut_L (0x29)
PressOut_XL (0x28)
Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit Bit bit bit bit bit
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
pressure magnitude
2/9
DocID026298 Rev 1