Computers innately consist of transistors that take two forms: on or off. You may be thinking, “How can a computer do something as basic as representing a number using these transistors?”
Let’s take the first small step and use these transistors to represent 1 and 0. We can perceive a transistor in an on state to be 1 and a transistor in an off state can be considered 0. We call this single unit of information a bit. A bit can take a value of either 0 or 1.
The following example shows this using bulbs.
Now, we can use multiple bits together to represent bigger numbers as well. For example, if we combine 4 bits together, we will have 16 unique combinations. This is because each bit can take two values (0 or 1), so four bits together means . We can label each of these 16 combinations with numbers from 0 to 15. Thus. we can represent 16 unique numbers with just 4 bits.
Now, the question arises, “How do we label these combinations systematically?” Turns out using power’s of two systematically give us a nice rule for labeling as well. Some powers of two are:
Now the cool thing is that you can make any positive integer by adding powers of two. For example:
If you have 4 bits now, you can imagine that those 4 bits represent a power of 2. The rightmost bit would represent the power, the second from the right represents power, and so on. Any of these 4 bits being 0 or 1 represent whether that two’s power contributes to the sum for that number or not. For example, if the first bit from the right is 0, then the number does not need the first power of two in its sum. This way, we can represent the numbers from the above example using 4 bits as:
Here, since two’s first two powers are contributing to 3, we have the two rightmost bits’ 1 in 3 binary representation. This explanation hold for the other two examples too.
Given below is an interactive simulation for an 8-bit representation of a number. Continuing with our example of bulbs, a lit-up bulb represents that the power corresponding to that bit contributes to the number, while a dimmed out bulb represents that it does not.
Play around with the simulation and then answer the questions at the bottom to test your learning.
What is the maximum possible number that can be represented using 8 bits?
127
128
255
256
Free Resources