General Big Projects Small Projects About Contact

Train The Bases

What Is A Base?

A base, also known as radix, specifies the number of unique digits to represent a number.
The 3 most popular bases:
Decimal; base 10; uses digit 0 through 9.
Binary; base 2; uses digit 0 and 1.
Hexadecimal; base 16; uses digit 0 through 9 and A through F. (A = 10, B = 11,...., F = 15)

There are multiple ways to indicate which base is being used.
You can use a prefix; 0xC0 indicates a hexadecimal number; 0b11000000 indicates a binary number,...
You can use subscript; 19210 indicates a decimal number; C016 indicates a hexadecimal number, 110000002 indicates a binary number,...

How To Convert Decimal To Binary

First write down the values of the powers of 2 from right to left until you reach the biggest value that fits in your decimal number.
Go down the line. Take the highest power of 2, check if it fits into your number.

If it does, write down a 1 and subtract it from your number. This is your new number.
If it doesn't, write a 0 and move on to the next power.
After subtracting, move on to the next power and keep going until your number reaches 0.

If you reached 0, you should have the correct binary number.

SideProject3_TrainTheBases_Ex1

How To Convert Binary To Decimal

First write down the values of the powers of 2 from right to left above your number until you reach the end of it.

Add up all values that have a 1 under them.

That is it. You should have the correct decimal number.

SideProject3_TrainTheBases_Ex2

How To Convert Binary To Hexadecimal

Write down your number and split it into groups of 4 bits (a nibble) from right to left. You can add 0 to the front if you can't get an even amount.

Convert the value of each nibble into decimal numbers from left to right.
Write those values down from left to right until you are done.
Keep in mind that A = 10, ..., F = 15

This should give you the correct hexadecimal number.

SideProject3_TrainTheBases_Ex3

How To Convert Hexadecimal To Binary

Write down your number and split each digit.

Convert the value of each digit into a nibble from left to right.
Write those nibbles down from left to right until you are done.

This should give you the correct binary number.
(The images shows this conversion from bottom to top)

SideProject3_TrainTheBases_Ex4

How To Convert Decimal To Hexadecimal

There are multiple ways to do this.
The simplest way is to convert the decimal number into binary, and convert the binary to hexadecimal.

How To Convert Hexadecimal To Decimal

There are multiple ways to do this.
The simplest way is to convert the hexadecimal number into binary, and convert the binary to decimal.

In Conclusion

These are the basics of converting different bases.
But to make it fun and handy to train yourself; I made a quick program that generates a random number for each base, which you can then solve.
Just click on the black rectangle of the base you want to solve, and type away.
Click anywhere to unselect.
You cannot add wrong digits to the bases.

To check if you're correct, click the checkmark.
If you are correct, your number will become green.
If you are incorrect, your number will become red.
You can clear your number by clicking the trashcan button.

You can get a new random number by clicking the refresh button next to the base.
You will get a random number between 110 and 409510.


The code is made using a framework that we got from school, which uses SDL.
You can check the code on GitHub here.

You can also just download the program using the download button below.
Keep in mind, do not touch anything and just run the .exe titled "Project3_TrainTheBases", deleting anything or moving something might break the program.
If the program still breaks when running the first time, restart the .exe, this might fix it.

Big shoutout to this guy, his version of hex to binary trainer inspired me to make my own, but bigger.

The only sources I used to get here were wikipedia and the best teacher ever; Tom Tesch.