Image courtesy of Pexels

Number Bases, Sets & Boolean Logic.

A Tutorial for beginners…

RoarzOnRailz
Published in
8 min readOct 26, 2019

--

Soooooo… As it turns out I studied my little butt off for a maths test and then flunked dramatically not even answering 1 question. Not because i didn’t know the physical formula of the math. But because Iwasn’t aware of what 1 symbol meant. So i decided to delve a little further and try my best to maintain a growth mindset vs a fixed one and write a blog to consolidate my learning. Whilst writing this i will continue my research and hopefully be better prepared for the next one.

Lesson 1

First of all so that i never…ever forget….base 16 can be prefixed with 0x. If you take 1 thing away from this lesson please remember this so that you don’t find yourself in my shoes! 😂.

Also Trecentosexagesimal is a word 🤷‍♀️who would have thought 😂. It is the descriptive word for the number system with a base 360. so there ya go….thats out there now for yall to know……moving right along.

The basics (Number systems & bases)

What is a number system & Base?

A number system is defined as a system of writing for expressing numbers. It is the mathematical notation for representing numbers of a given set by using digits or other symbols in a consistent manner.

The value of any digit in a number can be determined by:

  • The digit
  • Its position in the number
  • The base of the number system

There are various types of the number system in mathematics. The four most common number system types are:

  1. Decimal number system (Base- 10)
  2. Binary number system (Base- 2)
  3. Octal number system (Base-8)
  4. Hexadecimal number system (Base- 16)

In english please…

Ok so the easiest way to understand is that the number system we all know and are familiar with is Decimal. This is because its the number system us Human use everyday.

Decimal contains 10 digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9

Because decimal contains 10 digits its known as a base 10. Please note that the word Base can be replaced with Radix. It means exactly the same thing.

So if a decimal system has 10 digits and is known as a base 10. Then a Binary system which is a Base 2 must have how many digits?…….

Yes 👏 you got it peeps ! it has 2 digits. the digit 0 and the digit 1!.

Cool cool cool cool ……

Now that we got the B99 Reference out of the way….lets get on with it!

The other thing you should know about number systems is this. Once we move above the decimal number system the numbers are replaced with Letters.

An example:

Base 11( Undenary): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A ← — — — 👀 A means 10

base 14( Quattuordecimal): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D ← — — — 👀 A means 10, B means 11, you get it, D means 13.

base 16(Hexadecimal): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

I think were getting a pretty good hold of number systems guys. So essentially A number system is a different way to express numbers as we know them( decimal) Using different bases ! like Base 2 (Binary) or Base 16(Hexadecimal). Also don’t forget that once we get over 9 we use letters A,B,C etc…Now lets learn how to convert between them !!!! :).

Converting between different Number systems

Lets do it !!

true story !

The 2 formulas you need to know

That right guys!…and gals !! there’s only 2 formulas you need to know in order to scrape by here. Yes there are other easier ways to convert between certain bases but as long as you know these 2 formulas you will always get out of trouble no matter what!!! so lets go!!!!

From anything to Decimal

As we discussed earlier decimal is the Number system that us humans use every day of our lives and is a base 10 remember? so it only makes sense to want to convert things to it. Its our human way or no way !!!! yeah that right aliens !! ….Ok so on to the formula.

first of all load up this calculator in the oher window so you can check your results. https://www.rapidtables.com/convert/number/base-converter.html

If the number were converting from is 100100 (Binary). The we know the the Base of Binary is 2.

To convert any other number base to Decimal we lay out the number base were converting to the power of as follows.

In this example we have used 6 columns because there are six digits in the binary number. There will be as many columns as what there are digits in the number we are converting from.

Also note that because we the base we are converting from is 2 every column contains the number 2. If we were converting from hexadecimal or base 16 then they would all contain 16, octal or base 8 they would all contain 8 etc….

we then simply increase the power from zero and add 1 each time. until we fill the column.

Now we work out the math for this column.

Now remember that anything to the power of 0 is always 1 so the first column should always be 1. and then work out what the next column is.. 2 to the power of 1 is? …. etc.

All i have done above is place the answers in the column below. This just helps you visualise whats going on.

Now we add the Number were converting into the table from left to right 1 digit in each column.

then simply multiply each digit by the one above it that we just put in there and put the answer below…..like so …Were just working down the table to visualize it.

Now just add the bottom row together!

32 + 0 + 0 + 4 + 0 + 0 = 36

Congratulations !!! you just converted a number from base 2 Binary to base 10 Decimal!!!!

So its not as hard as you thought right ! lets do a quick recap and then we can move on to the second formula.

  1. Layout the physical number of the number base we are converting from as many times as….. how many digits are in the number we are converting.
  2. From right to left start at 0 adding 1 each time and work out what the number to the power of is(place it in the column below). remember a number to the power of 0 is always 1 and to the power of 1 is always itself.
  3. layout each digit in the number we are converting from left to right and multiply each digit by the digit above it(the result of the previous calculation).
  4. Add the results of the previous calculation together and whala! you have a decimal number !! (remember to check your results on the calculator i provided!)

Go right ahead and try a few examples. make sure you have your head around this !!…..ill wait

Formula 2 From Decimal to Anything!

Now we know how to convert a number from any other number system or base to Decimal how do we convert from Decimal to any other number Base?

As follows…

So to keep things simple lets use the same number we used above so you can see a proven result. This will work with any number form any base that your trying to convert though.

So to convert 36 to Binary or Base 2 we essentially divide the Decimal number by the base we want to convert it into…..figure out the leftover of that result so that we have a whole number and then divide the remaining result by the base we are trying to convert to and repeat.

We keep doing this until the result is less than the base we are converting to.

example:

36/2 = 18 … 0
18/2 = 9 …0
9/2 = 4.5… ?

What happens now that its not a whole number ? we need to make this a whole number so we give the leftover to the result. To do this we multiply the number after the decimal by the number base we are converting to. For eg. .5 x 2 = 1 … Now we can cross out the .5 and store the result and continue. This will work for any number base not just 2.)

36/2 = 18 … 0
18/2 = 9 …0
9/2 = 4… 1
4/2 = 2… 0
2/2= 1… 0

Now that we have a result smaller than the number base we are converting to it become our final result. like this

36/2 = 18 … 0
18/2 = 9 …0
9/2 = 4… 1
4/2 = 2… 0
2/2= 1… 0
…………..1

So this number looks kinda familiar right? just one thing …. its upside down !!! simply lay out the number from bottom to top and we have our binary number !

110110

and thats is…you did it!

You now know both formulas. you can officially convert between any number base to any other number base!

I would recommend trying a few examples from all different bases to build you confidence. There are some shortcuts once you feel familiar with this. But ultimately you can do it all with these 2 formulas and i feel its a great logical way to lay it out! Simply use decimal as a gateway between any 2 bases!

Now you know what a number system is and a number Base or Radix ! and how to convert between any base to any other base.

I will post a link here shortly to the next tutorial which will cover SETS and BOOLEAN LOGIC including truth tables!

Feel free to connect with me on Linkedin !! https://www.linkedin.com/in/roarzonrails/

--

--