Ron Mikhael Surara

Ron Mikhael Surara

Saturday, March 14, 2015

What I Learned in CompSci #36: Binary and Conversion

Binary
     -A binary number can only contain 2 digits, 1's and 0's
     -Another name is base-2
Example: 10, 1010, 1101




Origin of Word
     -The prefix "bi" means 2 in Latin. Binary only has 2 digits, 1 and 0.
     -It is also called base-2 because the column values are the powers of 2

Decimal
     -The number we are used to seeing
     -Has 9 digits, 0-9
     -Also called base-10, because the column values are the powers of 10
Example: 2, 10, 13




HexaDecimal
     -Contains 16 digits, 0-9 and A-F
     -Also called base-16
Example: 2, A, 3A

Conversion
Binary - Decimal(Positional Notation)
The value of a bit is equal to the value of its place number. Just convert the bits to its corresponding value, then add them.


So 1101 = 13


Decimal - Binary(Finding the Largest Number)
The technique here will be based on Sir Tom's technique(actually this is Sir Tom's)
First, find the largest possible number of the column(of the power of 2) that you can subtract from the decimal number, the (largest possible)number will then be a binary number in its column. Then just repeat the process on the difference until you get 0.


Converting 13 to Binary, which is 1101


Binary - Hexadecimal(4 bits = 1 hex digit)
First, divide the binary number by 4. Then the powers of 2's exponent will repeat every 4 digits. Just look at the picture. :)
Divide it by 4's, then treat it like a binary, converting to decimal, except use hexadecimal numbers.

Hexadecimal - Binary(1 hex digit = 4 bits)
The process is the same, except do it backward

Decimal - Hexadecimal(Dec-Bin-Hex)
There are 2 ways, the hard-complicated way, or the easier, but probably longer(the easiness will pay off) way. I'll tell you the easier way.
Just convert to Binary first, before converting to Hexadecimal.

Hexadecimal - Decimal(Hex-Bin-Dec)
The same, Binary first before decimal