Converting between decimal numbers and 8-bit binary numbers

1、Convert the decimal number 168 to a binary number:
  • 128 is less than 168 so the left most bit in the binary number is a 1. 168 - 128 = 40.
  • 64 is not less than or equal to 40 so the second bit from the left is a 0.
  • 32 is less than 40 so the third bit from the left is a 1. 40 - 32 = 8.
  • 16 is not less than or equal to 8 so the fourth bit from the left is a 0.
  • 8 is equal to 8 so the fifth bit from the left is a 1. 8 - 8 = 0. Therefore, the bits to the right are all 0.
2、Convert the binary number 01110000 to a decimal number:
0 x 20 = 0  
0 x 21 = 0  
0 x 22 = 0  
0 x 23 = 0  
1 x 24 = 16
1 x 25 = 32
1 x 26 = 64
0 x 27 = 0  
__________
 = 112

你可能感兴趣的:(binary,between,DECIMAL,Numbers,Converting)