Binary Numbers and Codes

Binary Numbers and Codes

Binary Numbers Basics

  • Binary number system uses two digits, 0 and 1, also referred to as bits.
  • Bit is a contraction of binary digit.
  • Binary numbers are base-2 numbers as opposed to decimal numbers which are base-10.
  • Each position in a binary number represents a power of 2.

Binary Arithmetic

  • Binary addition, subtraction, multiplication, and division follow similar rules to decimal arithmetic, but only involve 0s and 1s.
  • Binary addition involves carrying over values to the next higher bit if the sum exceeds 1.
  • Binary subtraction involves borrowing from the next higher bit if the subtrahend is larger than the minuend.
  • Binary multiplication and division are simpler than their decimal counterparts as they involve multiplying or dividing by 2 only.

Binary to Decimal Conversion

  • Converting a binary number to a decimal number involves multiplying each bit by 2 raised to the power of its position and adding all the values.
  • For example, 1101 in binary is 13 in decimal (12^3 + 12^2 + 02^1 + 12^0).

Decimal to Binary Conversion

  • Decimal to binary conversion involves continually dividing the decimal number by 2 and recording the remainder until the quotient is 0.
  • The binary equivalent is the sequence of remainders read from the bottom up.

Binary Codes

  • Binary codes are used to represent characters or instructions in computer systems.
  • Common types of binary codes include binary-coded decimal (BCD), ASCII, and Unicode.
  • Binary-coded decimal (BCD) is a 4-bit binary code used to represent the 10 decimal digits 0 to 9.
  • ASCII (American Standard Code for Information Interchange) represents alphanumeric characters using 7-bit binary numbers.
  • Unicode is an extension of ASCII, using 16-bit binary numbers, allowing representation of a much wider range of characters.

Data Storage

  • Binary numbers and codes form the basis of data storage in digital systems.
  • Files, images, audio and video data are all stored and transmitted as binary codes.

Error Detection and Correction

  • Binary numbers are also used in error detection and correction methods such as parity checking and Hamming codes.
  • Parity checking helps detect single bit errors by adding an additional bit, making the total number of 1-bits either even (even parity) or odd (odd parity).
  • Hamming codes can detect and correct single bit errors by adding additional parity bits to data words.