MCS-012 Computer Organisation and Assembly Language Programming

First year, Semester 1

Decimal Representation in Computers

Computers fundamentally operate using the binary number system, which uses only two digits: 0 and 1. However, humans commonly use the decimal system, which uses ten digits: 0 through 9. To bridge this gap, computers need to convert and represent decimal numbers in a way that they can process while maintaining a format that is understandable to humans.


Representing Decimal Numbers

In computing, decimal numbers can be represented in several ways:

  1. Binary-Coded Decimal (BCD)
  2. Floating-Point Representation


Binary-Coded Decimal (BCD)

Binary-Coded Decimal (BCD) is a method of representing decimal numbers where each digit of the decimal number is represented by its own binary sequence. This means that each decimal digit from 0 to 9 is converted to its four-bit binary equivalent.

Example: Representing 93 in BCD

  • Decimal 9 is 1001 in binary.
  • Decimal 3 is 0011 in binary.

So, 93 in decimal is represented as 1001 0011 in BCD.


Floating-Point Representation

Floating-point representation is used to represent real numbers (numbers with fractional parts). It allows for a very wide range of values by using scientific notation. A floating-point number is typically represented in computers using the IEEE 754 standard, which divides the number into three parts:

  1. Sign bit: Indicates if the number is positive (0) or negative (1).
  2. Exponent: Represents the power of the base (usually 2) to scale the significand.
  3. Significand (or Mantissa): Represents the precision bits of the number.

Example: Representing 9.3 in IEEE 754 single precision

  • Convert the decimal to binary: 9.3 (approx 1001.0100110011 in binary).
  • Normalize the binary number: 1.0010100110011 × 2^3.
  • The sign bit is 0 (positive number).
  • The exponent is 3 (with a bias of 127): 3 + 127 = 130, which is 10000010 in binary.
  • The significand is the fraction part: 0010100110011 (padded with zeros to fit 23 bits).

So, 9.3 in IEEE 754 single precision is represented as: 0 | 10000010 | 00101001100110000000000


Character-Based Representation

For representing decimal digits as characters, computers use character encoding schemes like ASCII (American Standard Code for Information Interchange). In ASCII, each decimal digit is assigned a unique 7-bit binary code.

Example: Representing '9' in ASCII

  • The ASCII code for '9' is 57.
  • 57 in binary is 0111001.

So, the character '9' is represented as 0111001 in binary in ASCII.

Report an issue

Reporting: Decimal Representation in Computers (topic)

Related Posts