Karnataka II PUC Computer Science (KSEAB) study materials
Karnataka II PUC Computer Science (KSEAB) study resources

Karnataka II PUC Computer Science (KSEAB): Data Representation

Karnataka II PUC Computer Science (KSEAB) · Work through your exam, one topic at a time.

All guide sections

Data Representation

Data Representation

This domain tests number systems, conversion, binary arithmetic, signed-number representation and character codes. Decimal uses base 10, binary base 2, octal base 8 and hexadecimal base 16. Each hexadecimal digit maps to four binary bits; each octal digit maps to three.

Rules

  • To convert decimal to base b, divide repeatedly by b and read remainders upward. To convert to decimal, sum digit times b raised to its position.
  • In 8-bit sign-magnitude, the leftmost bit is the sign; +5 = 00000101 and -5 = 10000101.
  • In 1's complement, invert all bits; in 2's complement, invert and add 1. The 2's complement range for n bits is -2^(n-1) to 2^(n-1)-1.
  • BCD encodes each decimal digit in 4 bits; ASCII is a 7-bit code; Unicode supports multilingual characters.

Worked example

Represent -5 in 8-bit 2's complement. +5 = 00000101. Invert: 11111010. Add 1: 11111011. Check: the place values are -128 + 64 + 32 + 16 + 8 + 2 + 1 = -5. So 11111011 is correct.

Traps

Do not forget leading zeros in a fixed width. In 2's complement, 10000000 is -128, not -0. Binary addition carries must be handled; ignore only the final carry beyond the fixed width when appropriate. Hex 1A = 00011010, not 00011011.