Data representation refers to the methods used internally to represent information stored in a computer. Computers store various types of information such as numbers, text, graphics, and sounds.
Number System
- The number system is a technique used to represent numbers within a computer's architecture.
- Every value saved to or retrieved from computer memory adheres to a specific number system.
Types of Number Systems
- Binary Number System: Known as the Base 2 system, it is highly efficient for computers but not for humans. It contains only two unique digits, 0 and 1. A string that contains any combination of these two digits (where each digit is called a bit) is known as a binary number. Computers calculate input in binary form, and digital computers internally use the binary number system to represent data and perform arithmetic calculations. For example, (10101)2, where 2 indicates the base of the binary number.
- Decimal Number System: The decimal number system is the one we use in our daily lives. It consists of 10 digits, from 0 to 9, which can represent any numeric value. It is also known as the Base 10 system or the positional number system. For example, (1275)10, where 10 indicates the base of the decimal number.
- Octal Number System: This system consists of 8 digits, from 0 to 7, and is known as the Base 8 system. Each position of an octal number represents a successive power of eight. For example, (234)8, where 8 indicates the base of the octal number.
- Hexadecimal Number System: This system provides a shorthand method for working with binary numbers. It contains 16 unique digits: 0 to 9 and A to F, where A represents 10, B represents 11, and so on up to F, which represents 15. It is also known as the Base 16 system or simply Hex. Each position of a hexadecimal number represents a successive power of 16.
For example, (F9D)16
Here, 16 represents the base of hexadecimal number.
Question for Data Representation
Try yourself:
Which number system consists of only two unique digits, 0 and 1?Explanation
- The binary number system consists of only two unique digits, 0 and 1.
- It is the most commonly used number system in computers.
- Each digit in a binary number is called a bit, and it is used internally by computers to represent and process data.
Report a problem
Conversion between the Number Systems
To convert a decimal number to binary, follow these steps:
- Divide the given number by 2.
- Note the quotient and the remainder. The remainder should be either 0 or 1.
- If the quotient is not 0, divide the quotient by 2 again and repeat step 2.
- If the quotient is 0, stop the process.
- The first remainder is called the Least Significant Bit (LSB), and the last remainder is called the Most Significant Bit (MSB).
- Arrange all remainders from MSB to LSB to form the binary number.
Binary to Decimal
- To convert a binary number to decimal, follow these steps:
- Multiply each binary digit by the corresponding power of 2.
- For the integral part, use positive powers of 2, and for the fractional part, use negative powers of 2.
- Sum all the resulting values to get the decimal equivalent.
Binary to Octal
To convert binary to octal, following steps are involved
- Step 1 Make the group of 3 bits from right to left. If the left most group has less than 3 bits, put in the necessary number of leading zeroes on the left.
- Step 2 Now, convert each group to decimal number.
Octal to Binary
Convert every digit of the number from octal to binary in the group of 3 bits.
Binary to Hexadecimal
To convert a binary number to its hexadecimal equivalent, follow these steps:
- Group the binary digits in sets of 4 bits each, starting from the right. If the leftmost group has fewer than 4 bits, add the necessary number of leading 0s to the left.
- Convert each group of 4 bits to its decimal equivalent.
Hexadecimal to Binary
For this type of conversion, convert each hexadecimal digit to 4 bits binary equivalent.
Question for Data Representation
Try yourself:
Which step is involved in converting binary to octal?Explanation
- To convert binary to octal, the step involved is to make groups of 3 bits from right to left.
- Each group is then converted to its decimal equivalent.
- This grouping into sets of 3 bits helps in simplifying the conversion process from binary to octal.
Report a problem
Decimal to Octal
To convert a decimal number to its octal equivalent, follow these steps:
- Divide the given number by 8.
- Record the quotient and the remainder. The remainder will be a digit from 0 to 7.
- If the quotient is not 0, divide the quotient by 8 again and repeat step 2.
- If the quotient is 0 or less than 8, stop the process.
- Write each remainder from left to right, starting from the Most Significant Digit (MSD) to the Least Significant Digit (LSD).
Octal to Decimal
To convert octal to decimal, following steps are involved Step 1 Multiply each digit of octal number with powers of 8.
- Step 1 Multiply each digit of octal number with powers of 8.
- Step 2 These powers should be positive for integral part and negative for fractional part.
- Step 3 Add the all multiplying digits.
Decimal to Hexadecimal
To convert a decimal number to its hexadecimal equivalent, follow these steps:
- Divide the given number by 16.
- Record the quotient and the remainder. The remainder will be a digit from 0 to 9 or a letter from A to F.
- If the quotient is not 0, divide the quotient by 16 again and repeat step 2.
- If the quotient is 0 or less than 16, stop the process.
- Write each remainder from left to right, starting from the Most Significant Digit (MSD) to the Least Significant Digit (LSD).
Hexadecimal to Decimal
To converthexadecimal to decimal, following steps are involved:
- Step 1 Multiply each digit of hexadecimal number with powers of 16.
- Step 2 These powers should be positive for integral part and negative for fractional part.
- Step 3 Add the all multiplyingdigits.
Octal to Hexadecimal
To convert octal to hexadecimal, following steps are involved
- Step 1 Convert each digit of octal number to binary number.
- Step 2 Again, convert each binary digit to hexadecimal number.
Hexadecimal to Octal
To convert hexadecimal to octal, following steps are involved
- Step 1 Convert each digit of the hexadecimal number to binary number.
- Step 2 Again, convert each binary digit to octal number.
Computer Codes
- In computers, any character, such as an alphabet, digit, or special character, is represented by a unique coded pattern of 1’s and 0’s.
- These codes are composed of fixed-size groups of binary positions.
- The most commonly used binary coding schemes are:
Binary Coded Decimal (BCD)
- Developed by IBM, BCD is a system where four bits are used to represent each decimal digit.
- It uses binary digits to represent decimal digits (0-9) and has no limit on the size of a number.
American Standard Code for Information Interchange (ASCII)
ASCII is a standard character code used to store data so it can be utilized by other software programs. There are two types of ASCII codes:
- ASCII-7: A 7-bit standard ASCII code that allows for 27 = 128 unique symbols or characters (from 0 to 127).
- ASCII-8: An extended version of ASCII-7. It is an 8-bit code that allows for 28 = 256 unique symbols or characters (from 0 to 255).
Extended Binary Coded Decimal Interchange (EBCDIC)
In EBCDIC, characters are represented by eight bits. This code allows for 2^8 = 256 unique combinations of bits and stores information that is readable by other computers.
Question for Data Representation
Try yourself:
Which binary coding scheme uses four bits to represent each decimal digit?Explanation
- Binary Coded Decimal (BCD) is a binary coding scheme that uses four bits to represent each decimal digit.
- BCD allows for the representation of decimal digits (0-9) using binary digits.
- ASCII and EBCDIC are other binary coding schemes but do not use four bits to represent each decimal digit.
Report a problem
Logic Gate
A logic gate is a basic building block of a digital circuit that has two inputs and one output. The relationship between the input and the output is based on a specific logic. These gates are implemented using electronic switches such as transistors and diodes.
There are various types of logic gate as follows
1. AND Gate: This gate is also represented by (⋅), i.e. (A ⋅ B). It returns True only if both the conditions or inputs are True otherwise it returns False.
2. OR Gate: This is represented by (+), i.e. (A + B). It returns True if any one of the conditions or inputs is True and if both conditions are False, then it returns False.
∴ X = A + B
3. Inverter or NOT Gate: This gate is also represented by (′), i.e. A ′. It returns True if the input is false and vice-versa.
4. NAND Gate: It is basically the inverse of the AND gate. This gate is designed by combining the AND and NOT gates.
It returns False only if the both conditions or inputs are True otherwise it returns True.
5. NOR Gate: It is inverse of the OR gate. This gate is designed by combining the OR and NOT gates. It returns True only if both the conditions or inputs are False otherwise it returns False.
Note NAND and NOR gates are also called universal gates.
6. Exclusive-OR or XOR Gate: It performs based on the operation of OR gate.
It returns True only if one condition is true from both the conditions otherwise it returns False.
Tit-Bits
- Unicode utilizes 16 bits to represent symbols in data, encompassing non-English characters and scientific symbols from various languages like Chinese and Japanese.
- Ones' complement of a binary number refers to the value acquired by flipping all the bits. For instance, inverting 110100 results in 001011.