Bits, integers & floating point
The same bits can represent a number, an instruction, or a color.
The hardware sees a bit pattern. The operation decides what it means.
Raw representation.
Build a decision
| A | B | XOR |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
NAND can build any Boolean function. Combining small gates creates selectors, adders, and control.
What this model includes
Ideal Boolean logic. Electrical timing and noise are omitted.
What happens inside
Choose an interpretation
An unsigned n-bit integer spans 0 through 2ⁿ−1. Two’s complement reuses those bit patterns for signed arithmetic. The high bit has negative weight. Addition wraps modulo 2ⁿ at the bit level, but language rules can treat signed overflow differently. Endianness orders bytes in memory, not the numerical significance of a register.
Approximate real numbers
Floating point separates sign, exponent, and significand. Finite precision requires rounding. Many decimal fractions, including 0.1, have no exact finite binary representation. Addition is not associative after rounding; NaN, infinity, subnormals, and signed zero have special rules. FP32 and FP64 trade storage and throughput for precision and range.
What this means for your code
Low-level engineer
Understand carry versus overflow flags, rounding modes, alignment, and ABI data sizes. FP exceptions and fast-math assumptions change semantics.
Software developer
Use integer or decimal types for exact monetary rules. Reordering a numerical reduction can change its result even if the mathematics looks identical.
// JavaScript uses binary64 numbers
console.log(0.1 + 0.2 === 0.3); // false
console.log((255 + 1) & 255); // 0 (8-bit wrap)Read the actual specifications
These references supply the underlying contracts and implementation details. The diagrams here are simplified teaching models.