Hi, I would like to give a small tutorial about number systems in computer science.
Which number systems are commonly used in computer science?
Binary number system
Octal number system
Hexadecimal system
These three number systems are the most common in computer science with quite great importance. I would like to deal here also the conversions.
Let's get started. Let's assume we are to convert the decimal number 61 into a binary number. Binary numbers have the base 2 which means the number system consists of 2 numbers 0 and 1. Thus, all numbers from the decimal system can be represented.
The method we use is the residual method. This is one of the easiest methods. We take the number and divide it by 2. If we have something with 0.5 at the end, the remainder is 1 and the 0.5 are simply cut off. If the result is a smooth number, the remainder is 0. We do this until nothing is left. Only the rests are interesting, these are then read bottom-up. The whole thing can be checked for correctness here:
https://www.binaryhexconverter.com/decimal-to-binary-converter
We can also exploit the power representation, but here it is easy to get muddled.
6110→X2
128
64
32
16
8
4
2
1
0
0
1
1
1
1
0
1
→001111012⇔1111012
0+0+32+16+8+4+0+1=6110
It is also possible to represent decimal numbers in the binary number system. Here we have to multiply everything behind the decimal point. As soon as we get over 1 in the multiplication, we have a 1, otherwise it is 0. E.g. we have the number 10.24 as a decimal number. Let's convert that.
Why did I stop calculating further? Quite simply, it would take forever and three days.
Let's move on to the octal system. If you know or use Linux, you will have used the command chmod 755 or chmod 777 many times.
Here we have octal numbers in play.
Read = 4
Write = 2
Execute = 1
0...7
Suppose we want to convert the decimal number 61 into the octal system.
The octal system has the base 8. The conversion is similar as before. Here, too, we use the remainder procedure.
Another possibility is to convert the decimal number to the binary system, and from there to the octal system.
This works like this:
6110↓1111011111012↓↓7858→75
Assuming we want to convert from the decimal system to the hexadecimal system, we have to keep in mind that the hexadecimal system goes from 0−9 and from A−F.
A=10,B=11,C=12,D=13,E=14,F=15.
Again, we can use the remainder method.