IoT Fundamentals · Study deck
Number Systems and Data Units
Picture a device counter that rolls from a large positive value to a negative one after months in service.
Physics Phoebe is your guide for this deck.

After studying this chapter
Learning objectives
You will be able to:
- Explain: Signed arithmetic does not have a universal wrap rule: in C, an overflowing signed expression is undefined, and conversion of an out-of-range value into a signed field is implementation-defined.
- Explain: If a value can need bit 8, an 8-bit field cannot represent it; the next storage width is part of the data contract, not an implementation detail.
- Explain: The core rule is simple: binary is how hardware stores values, hexadecimal is the compact human shorthand for those bits, and decimal is what people usually read.
- calculate byte ranges from bit width and signedness
Major section
In 60 Seconds
The bits arrived, but the sender and receiver used different limits.
- Firmware means the program stored on a device to control its hardware.
- A payload means the part of a message that carries the application data.
- Binary, decimal, and hexadecimal are three ways to write the same quantity, and a data type is a fixed-width container with a known range.
Major section
Start With the Story
You will convert sensor values between number systems and select an integer width that covers their valid range.
- Binary, decimal, and hexadecimal can describe one quantity, but the next panel shows that a bit pattern alone does not establish a usable range.
Major section
Same Quantity, Different Notation
A length of two meters is the same length whether you write it in meters or in feet; only the label changes.
- The quantity eighty can be written as 80 in decimal, 0x50 in hexadecimal, or 01010000 in binary.
- The important idea is that a digital field has a fixed size, and that size is a budget.
Major section
Same Quantity, Different Notation (continued)
A notation change does not change the stored quantity.
- The amount never changes, but the notation does, and reading one notation as if it were another is a common mistake.
- Eight bits can hold exactly 256 different values.
- A reader should identify the base before interpreting a dump or report.
Major section
Same Quantity, Different Notation (continued)
The lower strip pairs each hex digit with its matching nibble.
- Choosing a data type means choosing how many values a field can ever represent, and what happens when a value tries to exceed that limit.
- The lower strip pairs each hex digit with four bits, which is why hex is a compact way to inspect a byte.
- This makes packet dumps shorter to read without changing the value stored in the bits.
Major section
Same Quantity, Different Notation (continued)
Width, signedness, and units still belong to the data contract; the three panels only change how one value is written.
- In 0xA6, the binary pattern is 1010 0110, so only weights under the one bits contribute: 128+32+4+2=166.
- The most significant bit carries the greatest weight, while the least significant bit carries one.
- That byte budget is why a counter, status field, or scaled sensor value must be sized before it is trusted.
Major section
Same Quantity, Different Notation (continued)
If a value can need bit 8, an 8-bit field cannot represent it; the next storage width is part of the data contract, not an implementation detail.
- The core rule is simple: binary is how hardware stores values, hexadecimal is the compact human shorthand for those bits, and decimal is what people usually read.
- That tidy mapping is why register dumps, MAC addresses, and packet hex views are written in hexadecimal rather than decimal.
- The first step is not to read it as decimal one hundred six; the prefix says it is hexadecimal.
Major section
Same Quantity, Different Notation (continued)
The notation did not change the value; it made the byte practical to inspect without writing eight separate bits.
- The One-Minute ViewBinary is the storage Hardware holds values as bits.
- Everything else is a more readable way of writing the same bits.
- Width is a budgetA field's bit width fixes its range.
Major section
Same Quantity, Different Notation (continued)
If the firmware documentation says bit 7 means "fault present," bit 5 means "battery low," bits 2-1 encode the operating mode, and bit 0 means "sample ready," the same byte becomes a field map.
- Hex is the shorthandOne hex digit equals four bits, so hexadecimal is the compact, exact view used for bytes and registers.
- Beginner ExamplesThe hex byte 0x50 is decimal 80, because the digit 5 is in the sixteens place: five times sixteen plus zero.
- A single byte can hold 256 distinct values, written as 0 to 255 unsigned.
Major section
Apply It: Choose a Data Type That Fits
Choosing an integer type is a budgeting decision.
- Worked Example: A Scaled Temperature FieldA sensor reports temperature from -40.0 to 125.0 degrees, stored in tenths of a degree.
- Scaling by ten gives an integer range of -400 to 1250.
- -> fits with margin [choose this].
Major section
Apply It: Choose a Data Type That Fits (continued)
A signed 8-bit type only reaches -128 to 127, far too small.
- A signed 16-bit type spans -32768 to 32767, which comfortably covers -400 to 1250 with large margin, so signed 16-bit is the smallest safe fit.
- IntermediateA counter must hold up to fifty thousand events before reset.
- AdvancedA field stores a voltage from 0.00 to 3.30 volts in hundredths.

Major section
Under the Hood: Ranges, Signedness, and Overflow
Values are wrong by amounts that depend on the digits.
- Understanding them lets you predict exactly what a field can hold and what happens when it cannot.
- Positional ValueIn any base, a digit's contribution is the digit times the base raised to its position.
- In production, number systems are about budgets and boundaries.
Major section
Under the Hood: Ranges, Signedness, and Overflow (continued)
Specify and test a wrap policy if the protocol requires one.
- Signedness costs one bit of magnitude, which is why a signed 8-bit field reaches 127 instead of 255.
- Unsigned Wraparound and Signed OverflowUnsigned N-bit results wrap modulo 2 to the power N rather than clamping.
- Common PitfallsReading hex as decimal: Without confirming the base, 0x20 can be mistaken for 20 instead of 32.
Major section
Under the Hood: Ranges, Signedness, and Overflow (continued)
Signed arithmetic does not have a universal wrap rule: in C, an overflowing signed expression is undefined, and conversion of an out-of-range value into a signed field is implementation-defined.
- Forgetting the sign bit: A signed type holds half the positive range of an unsigned type of the same width.
- Ignoring scaling in the range: Storing tenths multiplies the integer range by ten, which can push a value past a small type's limit.
- Hex and Nibble AlignmentBecause four bits form one hexadecimal digit, conversion between binary and hex is grouping, not calculation.
Major section
Checkpoint: Summary
Binary, decimal, and hexadecimal are three notations for the same quantity; always confirm which one you are reading.
- A data type is a fixed-width budget: an N-bit unsigned field holds 0 to 2^N minus 1, and a signed field holds -2^(N-1) to 2^(N-1) minus 1.
- Signedness costs one bit of magnitude, so a signed 8-bit field reaches 127, not 255.
- Unsigned fixed-width results wrap modulo 2^N rather than clamping, which can make counters and timers jump; signed overflow needs an explicit policy.
Deck summary
Key takeaways
The bits arrived, but the sender and receiver used different limits.
- You will convert sensor values between number systems and select an integer width that covers their valid range.
- A length of two meters is the same length whether you write it in meters or in feet; only the label changes.
- A notation change does not change the stored quantity.
- The lower strip pairs each hex digit with its matching nibble.
Retrieval practice
Recall check 1 of 2

Physics Phoebe says: answer from memory, then check your reasoning.
Q1How many distinct values can a single 8-bit byte represent?
Show answer
Answer: C Eight bits give 2 to the power 8, which is 256 distinct values, usually written as 0 to 255 unsigned.
Q2A field stores temperature in tenths of a degree over the range -40.0 to 125.0 C. Which fixed-width integer type is the smallest safe fit?
Show answer
Answer: C The scaled range is -400 to 1250, which needs a signed type and fits well within -32768 to 32767.
Retrieval practice
Recall check 2 of 2

Physics Phoebe says: answer from memory, then check your reasoning.
Q3A signed 8-bit counter is at its maximum value of 127, and the firmware adds 1 without any range check under an explicitly defined two's-complement wraparound rule. What value does it hold afterward?
Show answer
Answer: B Under the stated wrap rule, 127 + 1 leaves the 8-bit pattern 0x80, which represents -128 in two's complement.
Print reference
Answers
Answer key.
- C · Eight bits give 2 to the power 8, which is 256 distinct values, usually written as 0 to 255 unsigned.
- C · The scaled range is -400 to 1250, which needs a signed type and fits well within -32768 to 32767.
- B · Under the stated wrap rule, 127 + 1 leaves the 8-bit pattern 0x80, which represents -128 in two's complement.