[Tutorial] Converting Binary to Numbers and other way around (Easy)
#1

Tutorial
Converting Binary to decimals


Hello welcome to my third tutorial, this time i will try to explain the easiest way to convert binary numbers
to regular decimals and the other way around.
I learned this at school the other day and I thought i'd share it with you guys
(+ I didn't find any of these tutorials on the SA-MP forums). The way i'm going to show you is the easiest way according to my teacher.


Lets get started at the beginning, I am going to try to explain a tiny bit of what binary means and how it works.

If you do not know anything about binary than thats no problem.

The Tutorial:

Computers read one's and zero's and this is what binary excists off, in some ways it can mean this:
pawn Код:
1 = True or Yes
0 = Not true or false
A example in SA-MP can be in your server CFG
pawn Код:
...
Announce 1 //So this means it will announce you're server, 0 would mean that it won't announce it.
...
Now you probably are asking you're self "What does binary look like?", here's a example:
pawn Код:
10110111
//As you notice the number is 8 digits long, this is a default binary number.
Next we are going to take a look at bits, to convert binary to decimals you need to know how this works.
Same as there are 8 digits in binary there are 8 numbers of bits.
pawn Код:
128   64    32    16    8    4    2   1
/*looks familiar? they should because you're windows also has different verions (32 bit and 64 bit versions)
If you add all these numbers together you will also get a familiar numbers which is 256, this number has to do with a IP Adres (you're gateway). anyway lets move on to the actuall converting part!*/
To convert binary to decimals we are going to place the 8 digit binary number under these 8 numbers of bites,
it looks likes this:
pawn Код:
128   64    32    16    8    4    2   1

1     0     1      1     0    1   1   1
/*Maybe you can already guess what we are going to do, if you payed attention to what the one's and zero's mean.
If you forgot (1 means true and 0 means false).*/
Converting the binary:

I won't talk to much anymore, here's what converting it actually looks like:
pawn Код:
//If theres a 1 under a bite than it means its true so add it to the other bits where a 1 is under.
1 =  1 = 1
2 =  1 = 3
4 =  1 = 7
8 =  0 = dont count it
16 = 1 =  23
32 = 1 =  55
64 = 0 = dont count it
128 = 1 = 83
//everything adds up to 183 so our conclusing is that the binary number 10110111, is in regular decimals 183.
Converting decimals to binary

Basicly to convert a regular decimal to binary you will do the same as above but the other way around,
example:
pawn Код:
//We want to convert the number 240 to binary, we take the 8 bit numbers again:
128   64    32    16    8    4    2   1
//And now we will go from right to left to see what numbers of bits we need to get 240, so:
128 = 1
64 = 1
32 = 1
16 = 1
8 = 0
4 = 0
2 = 0
1 = 0
//So 240 in binary is 11110000
Well this is the end of my tutorial and I hope you learned something of it! I hope i was clear enough and if you have any questions feel free to leave a comment!
Reply
#2

thread titles wrong, because binary is a numeral system you can't convert binary to numbers, just doesn't make sense..(to base-10/decimal?) and we already have a thread here
Reply
#3

Quote:
Originally Posted by Ada32
Посмотреть сообщение
thread titles wrong, because binary is a numeral system you can't convert binary to numbers, just doesn't make sense..(to base-10/decimal?) and we already have a thread here
It does make sense, I had this on school and if you get something on school it is probably legit or am I getting scr*wed by my teachers? I dont think so. This is correct as far as I know, if anyone else with more experience in this can comment here than that would be great! And the thread title is not wrong.
Reply
#4

What he meant is that you can't convert binary representations to 'numbers', as binary numbers ARE numbers. You meant 'converting to decimal representation'.

Also, instead of limiting the tutorial to 128, you can generalize it by explaining that 1001.....1 equals 2^n-1 + ... + 2^0, where n is the length of the binary string.
Reply
#5

Quote:
Originally Posted by Infinity
Посмотреть сообщение
What he meant is that you can't convert binary representations to 'numbers', as binary numbers ARE numbers. You meant 'converting to decimal representation'.

Also, instead of limiting the tutorial to 128, you can generalize it by explaining that 1001.....1 equals 2^n-1 + ... + 2^0, where n is the length of the binary string.
On school they didn't go to far into this, i only learned how to do this thanks for you're reply!
Reply
#6

Bump! Anyone else?
Reply
#7

Quote:
Originally Posted by Voxel
Посмотреть сообщение
It does make sense, I had this on school and if you get something on school it is probably legit or am I getting scr*wed by my teachers? I dont think so. This is correct as far as I know, if anyone else with more experience in this can comment here than that would be great! And the thread title is not wrong.
Do I count as someone with "more experience" lol? He is correct in saying that the tittle doesn't really make sense. You are not "converting binary to numbers", as they are already numbers, and you are not really manipulating anything; if anything you are attempting to explain the mathematical notation that represents numbers (base 2, or binary, in this case).

You should also REALLY learn to take criticism to better your posts. Since you don't seem to take it very well, I am not even going to go into the issues with your post. I will say however, that you should only write tutorials on subjects you are pretty knowledgeable about, or at LEAST plan on researching a ton (dont mean this to sound mean, but its good advice).
Reply
#8

Quote:
Originally Posted by Kyosaur
Посмотреть сообщение
Do I count as someone with "more experience" lol? He is correct in saying that the tittle doesn't really make sense. You are not "converting binary to numbers", as they are already numbers, and you are not really manipulating anything; if anything you are attempting to explain the mathematical notation that represents numbers (base 2, or binary, in this case).

You should also REALLY learn to take criticism to better your posts. Since you don't seem to take it very well, I am not even going to go into the issues with your post. I will say however, that you should only write tutorials on subjects you are pretty knowledgeable about, or at LEAST plan on researching a ton (dont mean this to sound mean, but its good advice).
I do take criticism well but on the internet it can be understood wrong as you cant see my facial expression, and I will admit that I didn't know how to call this topic so yeah :X I just wanted to share my knowledge on how to convert binary to decimals then (or what ever its called)

anyway, thanks for your reply!
Reply
#9

Representation does not equal conversion. Please change the title's name
Reply
#10

Quote:
Originally Posted by BigETI
Посмотреть сообщение
Representation does not equal conversion. Please change the title's name
Changed.
Reply
#11

Y u no post this before I had my exam stupid?! Kidding, good tutorial but binary was easy anyways so was not even studying. xD Once you learn this, it's probably stuck in your head. Try to make a tutorial on hexadecimals. They are much more fun to explain. I know how to count them but heck I can't explain. xD
Reply
#12

Quote:
Originally Posted by Hansrutger
Посмотреть сообщение
Y u no post this before I had my exam stupid?! Kidding, good tutorial but binary was easy anyways so was not even studying. xD Once you learn this, it's probably stuck in your head. Try to make a tutorial on hexadecimals. They are much more fun to explain. I know how to count them but heck I can't explain. xD
Haha, well maybe I will someday but not anytime soon but thanks for your reply anyways !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)