Docsity

Binary to Decimal and Hexadecimal Conversion, Lecture notes of Number Theory

Partial preview of the text

Download Binary to Decimal and Hexadecimal Conversion and more Lecture notes Number Theory in PDF only on Docsity!

Binary to Decimal

Q Convert 00101101 to decimal

  1. Write out the binary columns
  2. Add up the numbers: 32 + 8 + 4 + 1 128 64 32 16 8 4 2 1 0 0 1 0 1 1 0 1

Answer: 45

Decimal to Binary

Q Convert 73 to 8-bit binary

  1. Find largest bin column less than 73 (64s)
  2. Then 73-64 = 9, so find largest col less than 9
  3. 9-8 = 1 128 64 32 16 8 4 2 1 1 1 1 Answer: 01001001

Hexadecimal nunbers

Hexadecimal is base 16: Hex Decimal Hex Decimal 0 0 8 8 1 1 9 9 2 2 10 A 3 3 11 B 4 4 12 C 5 5 13 D 6 6 14 E 7 7 15 F

Binary to hexadecimal

Q Convert 11000111 to hexadecimal

  1. Split the number in half to create two 4-bit binary numbers: 1100 and 0111
  2. Convert each half into a hexadecimal value: 1100 = 8 + 4 = decimal 12 = hex C 0111 = 4 + 2 + 1 = 8

Answer: C

Hexadecimal to decimal

Q Convert 3C to decimal

  1. First part is the 16s: 3 x 16 = 48
  2. Second part is units: C = 12
  3. Add them together: 48 + 12 = 60

Answer: 60

Decimal to hexadecimal

Q Convert 156 to decimal

  1. Divide by 16 to get the first part: 157 / 16 = 9 remainder 13
  2. Second part is the remainder: Remainder 13 = D in hex
  3. Join them together: 9D

Answer: 9D

Right binary shift

Q Apply a right binary shift of 2 to 01101000

  1. Remove the last two 0s: 01101000
  2. Add the 0s on the left end: 00 011010
  3. Check the 1s have moved 2 places right

Answer: 00011010 1 right: half; 2 right: quarter ( div by 4); 3 right: eighth (div by 8) etc...

Bits, Bytes and so on

8 bits in a Byte 1000 Bytes in a kiloByte 1000 kB in a Megabyte 1000MB in a Gigabyte 1000GB in a Terrabyte

Bits, Bytes and so on

Q Convert 4 GB to kiloBytes 4 x 1000 = 4,000 MB 4,000 x 1000 = 4,000,000 kB

Answer: 4,000,000 kB