Sign in

Intro to Computer Science / Unit 2: Binary and Data Representation

2.1 Binary Numbers

3 practice questionsNot yet reviewed

Notes

Binary is base 2: it uses only the digits 0 and 1. Each place value is a power of 2, doubling from right to left: 1, 2, 4, 8, 16, 32, 64, 128.

  • To convert binary to decimal, add the place values that have a 1.
  • Example: 101101 = 32 + 8 + 4 + 1 = 45.
  • To convert decimal to binary, subtract the largest power of 2 that fits, repeatedly.
  • Example: 13 = 8 + 4 + 1, so 13 is 1101.
  • With n bits you can make 2 to the power n different values. 8 bits give 256 values (0 to 255).

Practice

What is the binary number 1101 in decimal?
What is the decimal number 22 in binary?
What is the largest decimal number that can be stored in 8 bits?

Ready for more? Take the Unit 2 test.