AERO61021 Chap.8 Binary Number Formats in Data Acquisition
Binary Number Formats in Data Acquisition
Binary Number Formats in Data Acquisition explains why the number a computer displays can differ from the value a sensor produced. Acquisition hardware stores every reading as bits, and software applies a rule to interpret them.
The chapter builds unsigned integers from powers of two, shows how a sign bit extends the idea to negative numbers, and explains why practical systems use two's complement, in which the leading bit of a byte carries a weight of minus 128 and a signed byte spans minus 128 to 127. It then follows what happens when a value is too large for its container: the stored pattern stays the same, but a signed reading can flip sign, and a counter wraps from 127 back to minus 128 without any warning.
A second family of faults comes from reading a floating-point word as an integer, which leaves the shape of the data intact while multiplying its magnitude enormously. The skills are practical: decode a byte under each rule, size a format to hold the largest value expected, and recognise the signatures of overflow and reinterpretation on a plot before blaming the sensor or the rig.
What this chapter covers
- 01
Unsigned integers from bit weights
- 02
Sign-magnitude representation and its two zeros
- 03
Two's complement bytes and their range
- 04
Overflow and wrap-around in signed formats
- 05
Floating-point words misread as integers
- 06
Choosing a data type for counters and averages
Worked example · free
Find where a stored byte lands on the wrap-around dial
- 1Build 230 from bit weights: 128 + 64 + 32 + 4 + 2 = 230, so the pattern is 11100110.
- 2In two's complement the leading bit weighs minus 128 and the other bits add 64 + 32 + 4 + 2 = 102, giving minus 128 + 102 = minus 26.
- 1Check with the shortcut: because the leading bit is 1, the signed reading equals 230 minus 256, which is also minus 26.
Key terms
- Two's complement
- A signed binary scheme in which the leading bit carries a negative weight, giving one unique zero.
- Sign bit
- The leading bit of a signed number, which marks the value as negative when it is set.
- Wrap-around
- The jump to the opposite end of a format's range when a value exceeds the largest number it can hold.
- Floating-point number
- A binary format that stores a sign, an exponent and a fraction so that non-integer values can be represented.
Binary Number Formats in Data Acquisition FAQ
Why does my LabVIEW graph suddenly jump from 127 to minus 128?
The value has been converted to a signed 8-bit integer, whose largest value is 127. One step beyond that, the leading bit becomes 1 and is interpreted with a weight of minus 128, so the trace drops to the bottom of the range and starts climbing again. Use a wider integer or a floating-point type for the quantity.
Is sign-magnitude ever used for signed integers?
It is a useful teaching step, because it simply marks a number negative with its leading bit. Practical computers avoid it for integers, however, because both 00000000 and 10000000 would represent zero. Two's complement removes the duplicate zero and extends the negative range to minus 128 for a single byte.
How can a correct image come back with values in the billions?
If floating-point pixel values are saved and then reopened as 32-bit integers, each word is reinterpreted rather than converted. The spatial pattern survives because every pixel is affected in the same way, but the magnitudes become enormous. Converting one value back to its bits and testing the integer reading confirms the diagnosis.
Assessment move
Learn this topic by hand before relying on software. Write the eight bit weights, from 128 down to 1, at the top of a page and convert a dozen values in each direction until you can do it without counting on your fingers.
Then repeat the drill with the leading weight replaced by minus 128 so that two's complement becomes routine; check each answer with the shortcut that a signed reading equals the unsigned value minus 256 whenever the leading bit is set. Pair every conversion with a statement of the range of the format you are using, because most faults in acquisition code come from a value that did not fit.
Next, practise recognising symptoms rather than computing values. A trace that climbs steadily and then jumps to the opposite sign at a round binary boundary indicates overflow in a short integer. A trace whose shape looks right but whose magnitude is wrong by an enormous factor suggests that bits were reinterpreted between formats, often a floating-point value read as an integer.
A trace that seems clipped to a narrow positive band can mean a fractional value was forced into an integer type. In LabVIEW, look at the colour of each wire and the representation of each indicator, and watch for coercion dots where a conversion happens silently. Hovering over a wire with context help open shows its exact representation, which settles any doubt in seconds.
When you build the group project code, decide the data type of every stored or displayed quantity at the start and write it next to the variable, including counters, sample indices and averages. As a closing habit, keep a short log of any strange value you meet in the lab together with the bit pattern behind it; working back to the bits is the habit that turns a confusing plot into a precise fault report.