![]() |
VOOZH | about |
Binary representation is the method of expressing numbers using binary digits (bits). In digital logic, binary representations are important as they are the foundation for all computations and data processing in computers.
It is a way to represent positive numbers using only 0s and 1s. It is a system where numbers are expressed using only their magnitude, with no sign bit. In this system, all numbers are treated as positive, including zero.
Features of Unsigned Representation:
Limitations of Unsigned Representation:
Example: 4-Bit Unsigned Binary
Binary | Decimal Calculation | Value |
|---|---|---|
0000 | (0×23) + (0×22) + (0×21) + (0×20) | 0 |
0001 | (0×23) + (0×22) + (0×21) + (1×20) | 1 |
1010 | (1×23) + (0×22) + (1×21) + (0×20) | 10 |
1111 | (1×23) + (1×22) + (1×21) + (1×20) | 15 |
Binary Representation of Signed Numbers representation allows both positive and negative numbers. There are various signed binary representations.
In the sign bit method, the leftmost bit (MSB) is used to represent the sign of the number. A '0' in the MSB indicates a positive number and a '1' indicates a negative number. The remaining bits represent the magnitude of the number in binary form. The range of values in an n-bit system is from -2n-1 -1 to 2n-1 - 1.
For example, in an 8-bit signed binary system:
01000101 represents +69 in decimal (MSB is 0, so the number is positive).
11000101 represents -69 in decimal (MSB is 1, so the number is negative).
Limitations:
In the 1's complement method, negative numbers are represented by flipping all the bits of the corresponding positive number. The leftmost bit (MSB) indicates the sign. A '0' in the MSB represents a positive number and a '1' represents a negative number.
For example, in an 8-bit system:
00000101represents +5 in decimal.
11111010represents -5 in decimal (flip all bits of00000101).
Limitations:
The 2's complement method is used to represent both positive and negative numbers in binary. To find the 2's complement of a number, invert all the bits of the binary number and add 1 to the result. The 2's complement method eliminates the need for separate zero representations and simplifies arithmetic operations like addition and subtraction. The range of values in an n-bit system is from -2n-1 to 2n-1 - 1. It is widely used in modern processors due to its efficiency and ease of operation.
For example, in an 8-bit system:
00000101 represents +5 in decimal.
11111011 represents -5 in decimal (invert 00000101 to get 11111010, then add 1 to get 11111011).
Limitations:
Note: Despite these limitations two's complement remains the universal standard due to its efficient arithmetic operations and single zero representation. Modern processors include dedicated circuits to handle these limitations effectively.
IEEE 754 is the most widely used standard for representing floating-point numbers in computers. It uses three components: the sign bit, the exponent and the fraction (mantissa). These components allow for the representation of real numbers with a large range of values.
The single precision format consists of 32 bits and is divided as follows:
In this format, the number is represented as:
(-1)S× ( 1 + M) × 2E-127
The double precision format consists of 64 bits and is divided as follows:
The number is represented as:
(-1)S× ( 1 + M) × 2E-1023
Example (32-bit Single Precision): The number -13.25 in binary is represented as:
Sign bit: 1 (negative)
Exponent: 10000001 (8 in decimal)
Mantissa: 10101000000000000000000
Final representation: 1 10000001 10101000000000000000000
Features:
Limitations:
Gray code is a binary numeral system in which two successive values differ by only one bit. Unlike the standard binary system, where multiple bits change when counting from one number to the next, Gray code ensures that only one bit changes at a time. This feature makes Gray code especially useful in reducing errors that may occur in digital systems, particularly when transitioning from one value to another. It is commonly used in applications like rotary encoders, analog-to-digital conversions and digital-to-analog conversions where small changes are needed.
Working of Gray Code:
To convert a binary number to Gray code:
Example: To convert the binary number 011 to Gray code:
Start with the MSB: 0 (the same for both binary and Gray).
XOR the next bit (1) with the previous bit (0): 0 XOR 1 = 1, so the second bit of Gray code is 1.
XOR the final bit (1) with the previous bit (1): 1 XOR 1 = 0, so the last bit of Gray code is 0.
Thus, the binary number 011 converts to Gray code 010.
3-bit Gray Codes:
Decimal | Binary | Gray Code |
|---|---|---|
0 | 000 | 000 |
1 | 001 | 001 |
2 | 010 | 011 |
3 | 011 | 010 |
4 | 100 | 110 |
5 | 101 | 111 |
6 | 110 | 101 |
7 | 111 | 100 |
Features:
Limitations:
Binary-Coded Decimal (BCD) is a system for representing decimal numbers in binary form. In this system, each decimal digit is encoded as a 4-bit binary number. Each of the decimal digits, from 0 to 9, is assigned a unique 4-bit binary code, ensuring that decimal values are directly mapped into binary representations. BCD is often used in applications where precision in decimal representation is required, such as in financial systems, digital clocks and calculators.
Working:
In BCD, each decimal digit is individually represented by a 4-bit binary number. For example:
0 is represented by 0000 in binary.1 is represented by 0001 in binary.2 is represented by 0010 in binary.9, which is represented by 1001 in binary.Example: To represent decimal number 259 in BCD:
Decimal
2=0010(4-bit binary for 2)Decimal
5=0101(4-bit binary for 5)Decimal
9=1001(4-bit binary for 9)
Therefore, the decimal number 259 is represented as: 0010 0101 1001 in BCD. Each of the digits (2, 5 and 9) is represented as a separate 4-bit binary value. The length of the BCD representation grows with the number of digits in the decimal number.
Excess-3 (also known as XS-3) is a binary code used to represent decimal numbers. It is a form of Binary-Coded Decimal (BCD) where each decimal digit is represented by its 4-bit binary equivalent, but with an offset of 3 added to the binary value. This shift by 3 ensures that all the values are positive and avoids the need for negative digits, providing certain advantages in arithmetic operations. The main idea behind Excess-3 is to simplify arithmetic operations such as addition and subtraction and to ensure that all the digits are represented by a positive 4-bit value, thus making it easier for digital circuits to process them.
Working:
To convert a decimal digit into Excess-3:
0011) to the 4-bit binary value.Example: Excess 3 code for decimal number 4 is,
The binary equivalent of decimal
4is0100.Add
3(which is0011) to0100:0100+0011=0111.Therefore, the Excess-3 code for decimal
4is0111.