How can a chip use just two voltage ranges to store the number 45?
An Irish Rail display says your train leaves in forty-five minutes. The computer behind it can store forty-five using just two voltage ranges. How do those two ranges give you enough digits to write a number like that?
Think of a light switch: it can be off or on. A transistor can act as a switch in a circuit that produces a low or high voltage. A digital input can tell which range the voltage is in, even if the exact voltage varies a little within that range.
In this circuit, the first row maps the low voltage range to zero, and the second maps the high range to one. The ranges can be reliably told apart, so the circuit can read either digit. A single binary digit is called a bit.
Suppose an input voltage rises a little but stays inside the recognised low range the whole time. Using the same convention as before, what bit does the circuit read? Pick an answer.
Count the digits in the row: there are eight, including the two zeros on the left. Each position holds one bit, and a group of eight bits is called a byte.
Just as in decimal, each position has a weight. Start on the right at one, which is two to the power of zero. Double as you move left. Line up the bits above their weights. Add the weights under the ones: thirty-two plus eight plus four plus one equals forty-five.
Start at one on the right and double leftwards. Skip one hundred and twenty-eight and sixty-four. Take thirty-two, leaving twenty-two. Take sixteen, leaving six. Skip eight. Take four, then two. Nothing remains, so skip one. Write one for each weight you took and zero for each you skipped.
Now convert thirty-eight from decimal to eight-bit binary. Start with the largest weight that fits, subtract it, and work down through the columns. Pick the byte that has ones in exactly the places you used.
If you start the rightmost column at two, every place weight is twice what it should be. For one zero one, that mistake gives eight plus two. Start at one instead, and the same digits give four plus one, which is five.
Here’s a Leaving Certificate-style question: convert this byte to decimal and show your working. Find the weights under the three ones. Write sixteen plus four plus one, then give twenty-one in base ten. That line shows how you got your answer.