210 likes | 405 Views
Computer Codes. How data is Represented in computer system?. Computer Codes. Bit & Byte : In binary coding, every symbol that appears in the data is represented by a group of bits . The group of bits used to represented a symbol is called a byte.
E N D
Computer Codes How data is Represented in computer system?
Computer Codes • Bit & Byte : In binary coding, every symbol that appears in the data is represented by a group of bits. The group of bits used to represented a symbol is called a byte. • A byte (B)is the smallest transmittable character (smaller than a word) and is usually made of 8 digital bits.So 8b = 1B. • 'kbps' = kilo-bits per second. Afroza Nahar
Bit & Byte • Abitis1binary digit(b) • 0 • Abyteis 8 bits(B) • 0010 0100 • Note: • Kilo- means a 1000,Mega- means million,Giga -means billion • Kilobit (Kb) is 1,024 bits • Kilobyte (KB) is 1, 024 bytes • Megabyte (MB) is 1,048,576 bytes • Gigabyte (GB) is 1,073,741,824 bytes Afroza Nahar
Computer Codes • The commonly used computer codes for internal representation of data are • BCD (Binary Coded Decimal) • EBCDIC ( Extended binary-coded decimal interchange code ) • ASCII (American Standard Code for International Interchange ) Afroza Nahar
Computer Codes • BCD (Binary Coded Decimal)CODE : • One of the early memory codes. • BCD is a 6-bit code, which can represent 64(26) different characters. • In 6-bit BCD code, the four BCD numeric place position are retained, but two additional zone position are added. • This is sufficient number to code the decimal digits (10), alphabetic letters (26) and other special characters (28). See the figure: 4.2 page 36 • . The BCD equivalent of each decimal digit is shown in next slide. All decimal digits are represented in BCD by 4 bits. Afroza Nahar
BCD Equivalent of Decimal Digits Decimal Digits BCD Equivalent 00000 10001 20010 30011 40100 50101 60110 70111 81000 91001 Afroza Nahar
BCD CODE • e. g. Converting 4210 into BCD, however, produces the following results : 4210= 01000010 42 or 01000010 in BCD Afroza Nahar
BCD CODE • Example:Show the binary digits used to record the word BASE in BCD. • Ans: B = 11 0010 in BCD binary notation A = 11 0001 in BCD binary notation S = 01 0010 in BCD binary notation E = 11 0101 in BCD binary notation • Hence the binary digits 110010110001010010110101 BA SE Will recode the BASE in BCD • Example: Using the octal notation show the BCD coding for the word DIGIT. Afroza Nahar
EBCDIC Code • EBCDIC (Extended binary-coded decimal interchange code) : • The major problem with BCD code is that only 64 (24) different characters can be presented in it. This is not sufficient for providing decimal numbers (10), lower-case letters (26), capital letters (26), and a large number of other special characters (28+). • The BCD code was extended from a6-bits code to an 8-bits code. The added 2 bits are used as additional zone bits, expanding the zone to 4-bits. The resulting code is called theEBCDIC . • Since EBCDIC is an 8-bit code, It is possible to represent 256 (28) different characters, instead of 64 (26). Afroza Nahar
Extended binary-coded decimal interchange code (EBCDIC) • Example :Using binary notation , write the EBCDIC coding for the word BIT. How many bytes are required for this representation? • Ans: B = 1100 0010in EBCDIC binary notation I = 11001001 in EBCDIC binary notation T = 11100011in EBCDIC binary notation Hence, the EBCDIC coding for the word BIT in abinary notation will be 110000101100100111100011 B I T Afroza Nahar
ASCII • American Standard Code for International Interchange (ASCII): • ASCII has been adopted by several American computer manufacturers as their internal computer code. • The code is popular in data communications, is used almost exclusively to represent data internally in microcomputers • It is frequently found in the larger computers produced by some vendors. Afroza Nahar
ASCII • ASCII is two types: • ASCII-7 and • ASCII-8 • ASCII-7 is a bit code that allows 128 (27) different characters. The first 3 bits are used as zone bits and the last 4 bits indicate the digit. • ASCII-8 is an extended version of ASCII-7. It is an 8 bits code that allows 256 (28) different characters rather than 128 Afroza Nahar
ASCII • Examples : • Write the binary coding for the wordBOYin ASCII-7. How many bytes are required for this representation? • Write the hexadecimal coding for the word GIRL in ASCII-8. How many bytes are required for this representation? • Unicodeuses 16 bits and provides codes for 65,000 characters. • Used for foreign language support Afroza Nahar
Unicode • The Unicode worldwide character slandered provides two bytes – 16 bits to represent each letter, number, or symbol, with 2 bytes. • Unicode can be created to represent more than 65,536 different characters or symbols. • This total is enough for every unique character and symbol in the world, including the vast Chinese, Korean, and Japanese character sets and those found in known classical and historical text. • One major advantage that Unicode has over other text code systems is its compatibility with ASCII codes. Afroza Nahar
Collating Sequence • The value of an alphanumeric or alphabetic data element is usually the name of some object. Obviously, one would not like to perform any arithmetic on such data, but one may like to compare them, for arranging them in some desired sequence. • If we compare the alphabetic values A and B, which one will be treated a greater by compute? For an answer to such questions, it is necessary to have some assigned ordering among the characters used by the computer. This ordering is known as the collating sequence. Afroza Nahar
Whatever may be the type of computer code used, in most (not all –in BCD 0>9) collating sequences, the following rules are observed: • Letters are considered in alphabetic order (A< B<C> ………………………….<Z) • Digits are considered in numeric order (0 < 1 < …………………………<9) Afroza Nahar
How do computers represent data? • Most computers aredigital • Recognize only two discrete states:on or off • Use a binary system to recognize two states • Use Number system with two unique digits: 0 and 1, calledbits (short for binary digits) Afroza Nahar
What is abyte? • Eight bits grouped together as a unit • Provides enough different combinations of 0s and 1s to represent 256 individual characters • Numbers • Uppercase and lowercase letters • Punctuation marks Afroza Nahar
Step 1.The user presses the capital letter D (shift+D key) on the keyboard. Step 2.An electronic signal for the capital letterDis sent to the system unit. Step 3.The signal for the capital letter D is converted to its ASCII binary code (01000100) and is stored in memory for processing. Step 4.After processing, the binary code for the capital letter D is converted to an image, and displayed on the output device. How is a letter converted to binary form and back? Afroza Nahar