How Computers Represent and Process Information
From physical signals to bits
Binary foundations
Digital computers encode information using two stable states, commonly represented as and . A bit is one binary digit, and a byte is bits. Larger units often scale by powers of two, so and .
Why binary works
Binary is robust because electronic circuits can distinguish between two voltage ranges more reliably than many finely spaced levels.
Integers and negatives
Unsigned integers encode only nonnegative values, while signed integers usually use two's complement. For an -bit two's complement integer, the range is to . This representation simplifies arithmetic in hardware.
Common data representations
| Type | Example | Notes |
|---|---|---|
| Binary integer | Base-2 number | |
| ASCII character | for 'A' | Older character encoding |
| Unicode character | '你' | Supports many languages |
| Floating-point | Approximate real-number encoding |
How many bits are in a byte?
A byte contains bits.
Correct answer: 8
What is the range of an -bit signed two's complement integer?
Using the formula to with gives to .
Correct answer: From -128 to 127.
Floating-point approximation
Many real numbers are stored in floating-point form, which trades exactness for a wide range of values. This is why can produce a value that is very close to, but not exactly, in many programming languages.
Why can floating-point arithmetic produce rounding error?
Some decimal fractions repeat infinitely in binary, so they must be approximated.
Correct answer: Because many decimal fractions have no exact finite binary representation
Why is two's complement popular in computer hardware?
Two's complement lets arithmetic work consistently across positive and negative values.
Correct answer: It makes addition and subtraction simpler by using the same circuitry for signed numbers.