Representation of Numbers

Representation of Numbers

Binary and Decimal Systems

  • Every digital computer uses the binary number system for data representation, composed of just two digits, 0 and 1.
  • In contrast, humans normally use the decimal number system, which includes ten digits (0 to 9).
  • The binary system is based on powers of 2. For example, from right to left, 2^0, 2^1, 2^2 and so forth.
  • Changing a decimal number to binary involves dividing the decimal number by 2 and noting down the remainder until the dividend equals zero. The binary equivalent is the reverse of the noted remainders.

Hexadecimal Representation

  • The hexadecimal system includes 16 symbols: 0-9 to represent values zero to nine, and A-F to represent values ten to fifteen.
  • Hexadecimal numbers are useful in computing because they can represent every byte (8 bits) as two consecutive hexadecimal digits, thus providing a more human-friendly representation of binary-coded values.

Two’s Complement

  • Two’s complement is a method for representing signed integers (positive or negative) in binary.
  • To obtain the two’s complement of a binary number, first invert all the bits (0 to 1 and 1 to 0), then add 1 to the result.
  • The leftmost bit of a twos-complement number is the sign bit. If the sign bit is 1, the number is negative; if it’s 0, the number is positive.

Floating Point Representation

  • Floating point representation is a way to approximate real numbers in binary, where a number is represented by two main parts: the significand (or mantissa) and the exponent.
  • The mantissa provides precision, while the exponent expands the range of values that can be represented.
  • This is similar to scientific notation in decimals. For example, the number 300 can be represented as 3 x 10^2 in scientific notation.
  • Floating point representation allows computers to handle very large numbers or extremely small fractions.