Convalesco

Growing stronger every day!

Archive for November 30th, 2006

Learning how to read Binary

without comments

Some days ago I was reading at the handbook about the left shift operator “Wikipedia link didn’t help a lot, so I asked on IRC. The result was excellent! Now, although I’m not used to use binary by any means or understand on the fly the binary numbers - which means make on the fly translation from binary to decimal - but a guy show me a way to calculate binary numbers, the clue was:

Let’s say that we have this binary number: 1001. We have a binary number (base 2) composed by 4 elements/characters. Now to find a decimal we must apply the following formula: a*3^2 + b*2^2 + c*1^2 + d*0^1. Where a,b,c,d we must substitute the binary numbers from left to right, make sure you count the last character of the binary number as 0. So the result is: 1*2^3 + 0*2^2 + 0*2^1 + 1*2^0 = 8 + 0 + 0 + 1 = 9.

Isn’t that simple? Now back to our first issue, the left shift operator - link here - shifts the first operand the specified number of bits to the left. Now I don’t understand where the hell is going to turn useful such an operator in Object Oriented programming, but I hope to find out someday.
I’m happy enough to understand binary, you know.. I never really understood the famous Geek quote: There are 10 kind’s of people those who understand binary and those who don’t I hope to be able to laugh someday with that, I’ve read it a thousand times.

Written by Panagiotis Atmatzidis

November 30th, 2006 at 8:55 pm

Posted in Uncategorized