Torrid Fish

Back

Binary Numbers#

Decimal number#

The number that we see daily.

N10=Σai×10i,0ai<10N_{10} = \Sigma a_i\times10^i, 0\le a_i\lt 10

e.g. : 1510=1×101+5×10015_{10} = 1\times10^1+5\times10^0

Hex (Base-16) number#

N16=Σai×16i,0ai<FN_{16} = \Sigma a_i\times16^i, 0\le a_i\lt F ai={0,1,2,3,4,5,6,7,8,9,A,B,C,D,E}a_i = \{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=4668710B65F_{16} = 11\times16^3+6\times16^2+5\times16^1+15\times16^0=46687_{10}

Binary number#

N2=Σai×2i,0ai<2N_{2} = \Sigma a_i\times2^i, 0\le a_i\lt 2

e.g. : 1510=1×23+1×22+1×21+1×20=1111215_{10} = 1\times2^3+1\times2^2+1\times2^1+1\times2^0 = 1111_{2}

This method is most often used in computer,there are few terminology as shown below.

Sign Magnitude#

Info:

N=±NN'=\pm N

It can represent the number in [2n1+1,2n11][-2^{n-1}+1, 2^{n-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-3.

310=1 0112-3_{10}=1\space 011_2

1’s complement#

Info:

N=(2n1)NN' = (2^n - 1) - N

It can represent the number in [2n1+1,2n11][-2^{n-1}+1,2^{n-1}-1].

Just simply invert every bit.

Example#

We want to use 4 digits to represent 3-3.

3=(161)3=12-3 = (16-1) - 3 = 12

Thus, we have the representation of 3-3 :

310=1 1002-3_{10} = 1\space 100_2

2’s complement#

Info:

N=2nNN' = 2^n - N

It can represent the number in [2n1,2n11][-2^{n-1},2^{n-1}-1].

Invert every bit and add 1.

Example#

We want to use 4 digits to represent 3-3.

3=163=13-3 = 16 - 3 = 13

Thus, we have the representation of 3-3 :

310=1 1012-3_{10} = 1\space 101_2

Special Power of 2#

Unitnumbernumber
K (kilo)2102^{10}1024
M (Mega)2202^{20}1048576
G (Giga)2302^{30}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=0011BCD3_{10} = 0011_{BCD}
  • 3110=0011 0001BCD31_{10} = 0011\space 0001_{BCD}
  • 1910=1 1001BCD19_{10} = 1\space1001_{BCD} (Cout=1C_{out} = 1)
  • 810=0 1000BCD8_{10} = 0\space 1000_{BCD} (Cout=0C_{out} = 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
tags: Logic Design EECS1010#