Data and instructions that are presented in a written or typed format can only be understood by the user. If the data is not in the user’s language, s/he will not be able to understand it. It is the same way with the computer; the computer’s language is binary 0s and 1s. The computer cannot understand typed or written instructions or data. Whenever data or instructions or input to the computer it is first converted to 0s and 1s, these are called binary digits (bits). There are a number of methods that are used to represent data in computer system, namely: 1. Binary Representation
2. ASCII- American Standard Code for Information Interchange 3. EDCDIC-Extended Binary Coded Decimal Interchange Code 4. Binary Coded Decimal (BCD)
6. Ones Complement
7. Two’s Complement
Representation of Characters
Data used on the computer for input and output operations are expressed using characters because this is what we humans understand. These characters are broken down into three categories, namely: 1. Numeric-This include all the digits from 0 to 9.
2. Alphabetic-This include all the letters from A to Z and a to z. 3. Special CharactersThis includes punctuation, symbols, etc.
The code used to represent each character is usually a unique group of 7 or 8 binary digits (bits). There are several methods used to represent characters, namely:
➢ ASCIIThe most popular method used to represent characters in computers is the American Standard Code for Information Interchange. This is a 7-bit code. Sometimes an eight bit, called a parity bit, is added for checking purposes. ➢ EBCDICThis is an 8-bit code that is widely used on IBM machines. Extended Binary Coded Decimal Interchange Code.
NB:-These codes are called character codes and are widely used to represent non-numeric data.
The following table gives examples of both methods
|Character |ASCII |EBDCDIC | |+ |0101011 |01001110 | |- |0101101 |01100000 | |0 |0110000 |11110000 | |1 |0110001 |11110001 | |2 |0110010 |11110010 | |3 |0110011 |11110011 | |A |1000001 |11000001 | |B |1000010 |11000010 |
Representing Data Using BCD
Using straight binary to represent integers can sometimes be very tedious especially when representing large numbers, for example 896. The larger the denary number gets the more difficult the conversion method becomes. Using the BCD method eliminate this difficult task. In using the BCD method each digit is converted separately.
Convert 896 to BCD and binary.
BCD=1000 1001 0110
The only disadvantage in using BCD is that more bits are used to represent the denary number. NB:-When representing BCD each digit is represented using a 4-bit code. Representing Negative and Positive Numbers using BCD.
When representing negative and positive signs a 4-bit pattern which does not represent any of the digits is used. One method is
❑ 1010 for positive-because this = 10 and 10 is not a digit. ❑ 1011 for negative-because this = 11 and 11 is not a digit.
What is an integer? There are two methods that are used to represent integers. 1. Sign-and-Magnitude
2. Two’s Compliment
The sign-and-magnitude representation for an integer is one of the commonest methods used for coding signed integers and the steps are as follows:
1. Convert the decimal number to...