Professional Documents
Culture Documents
Discussion
Computers store information in binary. Numbers, letters, pictures, and
all other data that is stored on a computer is reduced to binary 1s and
0s to be stored in memory. For example, here is the decimal number
23 in binary:
10111 in binary
= (1 * 24) + (0 * 23) + (1 * 22) + (1 * 21) + (1 * 20)
= 16 + 4 + 2 + 1
= 23
Storing Numbers
Say that you had a computer that stored numbers using 4 bits.
Positive and negative numbers could be stored by essentially using
one of the bits to indicate whether the number is positive or negative.
With one of the bits essentially acting as the + or - sign, that leaves 3
bits to actually store the number. What are the maximum and
minimum numbers that could be stored?
Max number Min number
0111 in binary 1000 in binary
= +7 in decimal = -8 in decimal
Overflow!
What if you wanted to store a number bigger than +7 with 4 bits, like
+8? In this case, the number will wrap around. So if we add 1 to +7,
we would get binary 1000. But we’ve already set that number aside as
being -8! When a positive number wraps around to negative numbers,
it’s called overflowing.
Exercise
Practice converting numbers between decimal and binary:
Decimal Binary Binary Decimal
5 101 111
11 01101
18 11110 14
20 101110
37 1010111