Get job ready skills with Codenga     |       Career Paths 30% OFF     |        Limited time only

1d 21h
close
Cart icon
User menu icon
User icon
Lightbulb icon
How it works?
FAQ icon
FAQ
Contact icon
Contact
Terms of service icon
Terms of service
Privacy policy icon
Privacy Policy
Zdjęcie główne artykułu.

An introduction to numeral systems

A numeral system is nothing more than a certain way of writing numbers. Take a look:

45

This number is 45 in the decimal system. Decimal system is well known to each of us because we use it every day. This system has its own rules that determine how we write numbers, how we read them, how we perform various operations on them, etc.

In addition to the decimal system, we also have binary, hexadecimal, octal, ternary, and many others.

You're probably asking yourself: why should I learn other systems apart from decimal? Will knowledge of, for example, the binary or hexadecimal system be useful to me in the field?

Numeral systems in practice

There are situations where knowing an additional system may be useful. For example, in CSS we often use hexadecimal to specify colors. Alternatively, you may be implementing low-level software that operates directly on binary values.

In such technical applications, knowledge of various number systems may simply be essential.

So why don't we now look at the characteristic features of a few popular systems.

Decimal - the most obvious one for people

The base of the decimal system is...the number 10. There is nothing surprising here. Every number in this system is built from digits that belong to the set 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.

You can write any number by multiplying the digits by successive powers of 10. Example:

45 = 4 * 10^1 + 5*10^0

45 = 40 + 5

The decimal system is natural to us. Each of us has to deal with it every day.

Binary - the core of the computer

Computers don't understand the decimal system. Or at least they can't work with it directly. At its core, every computer works in binary. Let's get straight to an example.

101101 in binary system is the number 45 in decimal. As the name suggests in binary system the number 2 is the base. All digits belong to the set 0, 1. So now we will try to write our binary number in the form of successive powers.

101101 = 1 * 2^5 + 0 * 2^4 + 1 * 2^3 + 1 * 2^2 + 0 * 2^1 + 1 * 2^0

Now let's add the results:

32 + 0 + 8 + 4 + 0 + 1 = 45

Thus, we get 45 in the decimal system! Everything is correct. As you can see, converting from binary to decimal is not a particularly complicated operation.

Conversion

On the one hand, we are talking about the fact that computers use binary system for calculations. On the other hand it doesn't mean that you have to convert every number to binary. In practice, when you run programs, such conversion will be done "implicitly" by built-in, internal tools. So you can be a programmer without going beyond the decimal system at all.

However, there are situations when we need to work at a low level, directly operating in the binary system, for example. Such things are often encountered when programming digital circuits, writing controllers, and in many other areas.

Simply being able to work with such values and being able to do conversions between different systems can be very useful at a certain level.

Hexadecimal system

Let's look for a moment at another, quite popular system. The hexadecimal system is based on the number 16. And now the question arises - how to write numbers if we have only digits from 0 to 9?

The solution is simple. For digits above 9 we use letters from A to F. This gives us 16 different elements for the digits 0 through 9 and the letters A through F.

Let's go back to our decimal number 45. In hexadecimal it will look like this: 2D.

This system has its various uses. A good example is CSS colors, which are often written in hexadecimal. Here are some examples:

FFFFFF - white color

000000 - black color

Wanna learn more about numerical systems? Try this interactive Codenga course.