Binary Numbers#
Decimal number#
The number that we see daily.
N10=Σai×10i,0≤ai<10
e.g. : 1510=1×101+5×100
Hex (Base-16) number#
N16=Σai×16i,0≤ai<F
ai={0,1,2,3,4,5,6,7,8,9,A,B,C,D,E}
e.g. : B65F16=11×163+6×162+5×161+15×160=4668710
Binary number#
N2=Σai×2i,0≤ai<2
e.g. : 1510=1×23+1×22+1×21+1×20=11112
This method is most often used in computer,there are few terminology as shown below.

Sign Magnitude#
Info:
N′=±N
It can represent the number in [−2n−1+1,2n−1−1].
Use the first bit to record the magnitude, 1 means negative, 0 is positive.
Example#
We want to use 4 digits to represent −3.
−310=1 0112
1’s complement#
Info:
N′=(2n−1)−N
It can represent the number in [−2n−1+1,2n−1−1].
Just simply invert every bit.
Example#
We want to use 4 digits to represent −3.
−3=(16−1)−3=12
Thus, we have the representation of −3 :
−310=1 1002
2’s complement#
Info:
N′=2n−N
It can represent the number in [−2n−1,2n−1−1].
Invert every bit and add 1.
Example#
We want to use 4 digits to represent −3.
−3=16−3=13
Thus, we have the representation of −3 :
−310=1 1012
Special Power of 2#
| Unit | number | number |
|---|
| K (kilo) | 210 | 1024 |
| M (Mega) | 220 | 1048576 |
| G (Giga) | 230 | 1073741824 |
Binary Coded Decimal (BCD)#
A common coding method to code each
digit of a decimal number in terms of
binary bits.
(Since the number is between 0 to 9, so we need 4 digits)
Sometimes, BCD will have a carryout, which means the higer number is 1 or 0.
Example#
- 310=0011BCD
- 3110=0011 0001BCD
- 1910=1 1001BCD (Cout=1)
- 810=0 1000BCD (Cout=0)
ASCII#
ASCII (American Standard Code for Information Interchange) is the standard binary code for the set of alphanumeric characters, the character set includes :
- numerals
- alphabets
- special printable characters
- control characters
