Demo 1.2: Three Ways to Change Base
Four bases give twelve ordered pairs, and this is where the topic usually goes wrong. Twelve pairs look like twelve recipes, twelve recipes get learned as twelve recipes, and by the time you are asked for octal to hexadecimal under exam conditions there are eleven other procedures in the way.
It is not twelve things. It is three, and one of them costs no arithmetic at all.
The three methods
Section titled “The three methods”Any base into decimal. Multiply each digit by the weight of its position and add the products. That is the previous demonstration, used in the direction you already know, and it is one method rather than three: only the weights change between binary, octal and hexadecimal.
Decimal into any base. Repeated division for the whole part, keeping the remainders, and repeated multiplication for the fraction, keeping the whole parts. Again one method, and again only the divisor changes.
Binary to and from octal or hexadecimal. Regroup the bits, three at a time for octal and four at a time for hexadecimal. Nothing is multiplied, divided or added, because 8 is 2³ and 16 is 2⁴, so their digits are simply bits in bundles.
That third method is free, and being free changes the shape of the whole problem. Octal to hexadecimal has no direct method worth having, so you do not use one: you regroup into binary and regroup back out again. Two free steps beat any amount of dividing, and the twelve-entry table stops existing.
The first tab of this demonstration exists to make that visible before any method is taught, because a student who has the map does not have to memorise the routes across it.
How to use it
Section titled “How to use it”Which route to take is the map. Choose a base to start from and a base to arrive at, and the route lights up on a small graph of the four. The thick edges are the free ones and they connect binary to octal and to hexadecimal; the dashed edges cost arithmetic and they all lead to decimal. Ask for octal to hexadecimal and watch what happens, because there is no edge between them and the demonstration routes you through binary instead. Each step of the route is named, priced and worked out on the number you have loaded.
Regrouping bits is the free conversion in detail. The bits are drawn inside their groups with the padding shown in grey, so you can see where the groups start and which end the padding goes on. There is a switch that starts the groups from the wrong end on purpose, which is worth pressing.
Into and out of decimal is the two conversions that cost you something, worked one line at a time. Going in, a table of digits, weights and products with a running total. Coming out, a division table for the whole part beside a multiplication table for the fraction, with the answers read off in opposite directions. Use Next step rather than Show all the first time.
Try it yourself draws problems at random from all twelve pairs. Work them out on paper before typing anything in. Every number in it has an exact answer in every base, so nothing you are asked to produce will recur.
Changing Base
Twelve pairs of bases, three methods, and one of them costs no arithmetic at all.
Walkthrough
Section titled “Walkthrough”Step 1: Read the map before you learn any method
Section titled “Step 1: Read the map before you learn any method”Open Which route to take. It starts on octal to hexadecimal, which is the interesting case, so look at the graph first.
There are four bases and five edges, and there is no edge between octal and hexadecimal. That absence is not an oversight in the drawing. It is the honest answer: there is no direct method between those two worth having, because no whole number of octal digits makes up a whole number of hex digits until you reach four of one and three of the other.
The route the demonstration takes instead goes octal, binary, hexadecimal. Two steps, both of them thick, both of them free. Read the two step panels on the right and note the price of each: no arithmetic, twice.
Now try some other pairs. Binary to hexadecimal is one free step. Octal to decimal is one step that costs a multiply per digit. Decimal to binary is one step that costs a division per digit. Every one of the twelve pairs is some combination of those three, and nothing else is ever needed.
Step 2: Find the only mistake this conversion allows
Section titled “Step 2: Find the only mistake this conversion allows”Open Regrouping bits, which starts with 10110111.1 and groups it into hexadecimal.
Look at where the groups begin. The bits are gathered into fours running outward from the point in both directions, and the group that comes up short gets padded with zeros at its outer end. On the whole-number side that means padding on the left, and on the fraction side it means padding on the right. Both are harmless, in exactly the way that writing 0026 for twenty-six is harmless.
Now switch to Octal, 3 bits and watch the same bits regroup into threes. The answer is 267.4, which is the number from the reading, and the bits themselves never moved.
Then press From the outside.
Every digit changes, and the demonstration turns rose and tells you the value has changed too. Grouping the whole part from the left pads at the wrong end, so every bit is now being read against a weight three or four times too large. The result is 556 rather than 267, and this is the uncomfortable part: 556 is a perfectly well-formed octal number. Nothing about it looks wrong. If you make this mistake in an examination there is no internal contradiction to catch you.
The reason the point is the anchor is worth stating plainly. The point is where the exponents pass through zero, so the bit immediately to its left is worth 1 and the bit immediately to its right is worth a half. Those are the only two positions in the whole number whose weight you know without counting, and every other position is measured from them.
Step 3: Go into decimal, one digit at a time
Section titled “Step 3: Go into decimal, one digit at a time”Open Into and out of decimal and leave it on Into decimal, using weights. It starts on 245.37 in octal.
Press Next digit repeatedly rather than Show all. Each press adds one row: the digit, the power of eight its position represents, the weight as a number, the product, and the running total. After six presses the total is 165.484375.
Now load 30F.A9₁₆ and do the same. The procedure has not changed at all. The weights are powers of sixteen instead of powers of eight, the digits A and 9 stand for ten and nine, and the total comes to 783.66015625.
This is one method, and it is the method you already use without noticing whenever you read a decimal number. In binary it gets easier still, because every digit is 0 or 1 and there is nothing to multiply: name the weights above the 1s and add them.
Step 4: Come back out of decimal, and mind the direction
Section titled “Step 4: Come back out of decimal, and mind the direction”Press Out of decimal, using division and load 54.40625 → binary.
Two tables appear, and they are two separate calculations that never meet. Step through them.
On the left, the whole part is divided by two over and over and the remainders are kept: 54 gives 0, then 27 gives 1, then 13 gives 1, and so on until the quotient reaches zero. The digits arrive least significant first, so the answer is read upwards, from the last division to the first.
On the right, the fraction is multiplied by two over and over and the whole part of each result is taken as a digit: 0.40625 doubles to 0.8125 giving a 0, which doubles to 1.625 giving a 1, and so on until nothing is left. These digits arrive most significant first, so the answer is read downwards, in the order you produced them.
Put together, 54.40625 is 110110.01101 in binary.
Mixing up those two directions is the commonest error in the whole topic, and it is worth attaching a reason to rather than memorising. Dividing shifts the number one place to the right, so what falls off the end is the digit that was in the ones column, and you are peeling digits off from the bottom. Multiplying shifts the other way, so the digit that appears is the one nearest the point, and you are peeling from the top.
Now load 87 → octal and step through it. It is the same procedure with eight in place of two, and it gives 127.
Step 5: Try one where the arithmetic does not terminate
Section titled “Step 5: Try one where the arithmetic does not terminate”Still on Out of decimal, type 0.1 and leave the target on binary.
The multiplication column never reaches zero. The demonstration runs it out to sixteen digits, marks the answer as cut off, and says why: the number you typed has no exact form in base two, so no amount of further multiplying will produce one. This is the previous demonstration’s lesson arriving from the other direction, and it is a good check that you believed it the first time.
Step 6: Do twenty of them
Section titled “Step 6: Do twenty of them”Open Try it yourself and start on Whole numbers.
Before you calculate anything, look at the two bases and decide which of the three methods applies. That decision takes a second and it determines everything that follows, and doing it deliberately is the habit that makes the topic quick. If neither base is decimal, there is no arithmetic to do. If one of them is decimal, there is.
When you get one wrong, read which kind of wrong it was. Typing a digit that does not exist in the target base is a different mistake from getting the value wrong: it usually means a carry was missed, because any value large enough to need that symbol should have moved into the next column up.
Then switch to With a radix point and do a few more. Nothing new is required. The whole part and the fraction are separate calculations in every method here, and they always were.
Check your understanding
Section titled “Check your understanding”What is the quickest way to convert 5A7₁₆ to octal?
When grouping the bits of 10110111.1 into fours, where do the groups start and where does the padding go?
Match each pair of bases to the method it needs
Converting a decimal number to binary, why are the remainders from the repeated division read upwards while the digits from the repeated multiplication are read downwards?
Which of these can lose accuracy? Select all that apply.
Wrap-up
Section titled “Wrap-up”Five things to take away.
- Twelve pairs, three methods. Weights going into decimal, repeated division coming out of it, and regrouping between the powers of two. Choosing the method is most of the work.
- Regrouping is free. One octal digit is three bits and one hex digit is four, always, so these conversions cost no arithmetic and can only be got wrong in one way.
- Groups run outward from the radix point, and the padding goes at the outer end. Start them from the wrong end and you get a well-formed number that is not the one you were asked for.
- Octal to hexadecimal goes through binary. There is no direct route, and you do not want one, because two free steps are cheaper than any arithmetic.
- Divide and read upwards, multiply and read downwards. Attach that to what a shift does and it stops being something to memorise.
None of this has involved a negative number or a sum, which is deliberate. Everything so far is about writing quantities down. What a circuit does with them, starting with addition and the carry that makes it possible, comes next.
© 2026 Derek Molloy, Dublin City University. All rights reserved.