Character Floating Point Numbers Representation Representation of Character
Character & Floating Point Numbers Representation
Representation of Character (Information) Alpha Numeric Information The alpha numeric information like name of the student, college name etc. represented by string of characters. This information is represented by ASCII or EASCII or UNICODE character set format. ASCII The full form of ASCII is American Standard Code for Information Interchange. ASCII is a seven bit binary representation. It can represent 128 different symbols. EASCII The full form of EASCII is Extended American Standard Code for Information Interchange. EASCII is a eight binary representation. It can represent 256 different symbols. UNICODE The ASCII and EASCII character set can represent only upper and lower case alphabet. Other languages characters are necessary to develop multilingual systems. Unicode character set represents character from different languages like Japanese, Korean, South Asian languages. Unicode character set is a 16 -bit representation of the symbol.
Exponential Notation • The following are equivalent representations of 1, 234 123, 400. 0 x 10 -2 12, 340. 0 x 10 -1 1, 234. 0 x 100 123. 4 x 101 12. 34 1. 234 x 102 The representations differ in that the decimal place – the “point” -“floats” to the left or right (with the appropriate adjustment in the exponent). x 103 0. 1234 x 104 p. 122
Parts of a Floating Point Number -0. 9876 x Sign of mantissa Location of decimal point -3 10 Exponent Sign of exponent Mantissa Base p. 123
IEEE 754 Standard • Most common standard for representing floating point numbers • Single precision: 32 bits, consisting of. . . – Sign bit (1 bit) – Exponent (8 bits) – Mantissa (23 bits) • Double precision: 64 bits, consisting of… – Sign bit (1 bit) – Exponent (11 bits) – Mantissa (52 bits) p. 133
Floating Point Representation The IEEE 754 standard is use to represent real numbers on the majority of computer systems. It uses 32 -bit pattern to represent single precision numbers and 64 -bit pattern to represent double precision numbers. Sign bit 1 – bit Exponent E 8 -bit Fraction F 23 -bit Single Precision (32 -bit) Representation Sign bit 1 – bit Exponent E 11 -bit Fraction F 52 -bit Double Precision (64 -bit) Representation Equation 1 : Equation 2 : ± 1. F X 2 E-127 32 -bit representation ± 1. F X 2 E-1023 64 -bit representation In both cases, F is preceded with an implied one numeric and of binary point. If sign bit value is 0 then number is positive and if value is 1 then number is negative.
Example 1 : Store 5. 5 in 32 -bit format Step 1 : 5. 5 Step 2 : Make binary representation 101. 1 Step 3 : Normalize binary representation 1. 011 X 22 (± 1. F X 2 E-127) Step 4 : Get Exponent E-127=2 E=129 Step 5 : Convert exponent in 8 -bit binary 1000 0001 Step 6 : Number is positive, sign bit is zero. Step 7 : Convert fractional part in 23 -bit binary. 0110 0000 000 Step 8 : Put sign bit, exponent and fractional part. 0 1000 0001 0110 0000 000
Example 2 : Convert 0100 0000 1011 0000 0000 Step 1 : 0100 0000 1011 0000 0000 Step 2 : Place sign bit, exponent and fractional part 0 sign 100 0000 1000 0001 0111 0000 0000 exponent fractional part Step 3 : Sign bit is zero, number is positive. Step 4 : E=1000 0001 E=129 Step 5 : Put values in formula. ± 1. 011 0000 0000 X 2(129 -127) Step 6 : Number is positive, sign bit is zero. Step 7 : Simplify and discard extra zero. = ± 1. 011 X 22 = 101. 1 = 5. 5
Example 3 : Store 15. 5 in 64 -bit format Step 1 : 15. 5 Step 2 : Make binary representation 1111. 1 Step 3 : Normalize binary representation 1. 1111 X 23 (± 1. F X 2 E-1023) Step 4 : Get Exponent E-1023=3 E=1026 Step 5 : Convert exponent in 11 -bit binary 100 0010 Step 6 : Number is positive, sign bit is zero. Step 7 : Convert fractional part in 52 -bit binary. 1111 0000 0000 0000 Step 8 : Put sign bit, exponent and fractional part. 0 100 0010 1111 0000 0000 0000
Example 4 : Store -11. 75 in 32 -bit format Do it yourself.
Excess Notation • To include +ve and –ve exponents, “excess” notation is used • Single precision: excess 127 • Double precision: excess 1023 • The value of the exponent stored is larger than the actual exponent • E. g. , excess 127, 10000111 – Exponent 135 – 127 = 8 – Represents…
Example • Single precision 0 10000010 1100000000000 1. 112 130 – 127 = 3 0 = positive mantissa +1. 112 x 23 = 1110. 02 = 14. 010
Hexadecimal • It is convenient and common to represent the original floating point number in hexadecimal • The preceding example… 0 10000010 1100000000000 4 1 6 0 0 0
Converting from Floating Point • E. g. , What decimal value is represented by the following 32 -bit floating point number? C 17 B 000016
• Step 1 – Express in binary and find S, E, and M C 17 B 000016 = 1 10000010 1111011000000002 S 1 = negative 0 = positive E M
• Step 2 – Find “real” exponent, n – n = E – 127 = 100000102 – 127 = 130 – 127 =3
• Step 3 – Put S, M, and n together to form binary result – (Don’t forget the implied “ 1. ” on the left of the mantissa. ) -1. 11110112 x 2 n = -1. 11110112 x 23 = -1111. 10112
• Step 4 – Express result in decimal -1111. 10112 -15 2 -1 = 0. 5 2 -3 = 0. 125 2 -4 = 0. 0625 0. 6875 Answer: -15. 6875
Converting to Floating Point • E. g. , Express 36. 562510 as a 32 -bit floating point number (in hexadecimal)
• Step 1 – Express original value in binary 36. 562510 = 100100. 10012
• Step 2 – Normalize 100100. 10012 = 1. 0010010012 x 25
• Step 3 – Determine S, E, and M +1. 0010010012 x 25 S M S = 0 (because the value is positive) n E = n + 127 = 5 + 127 = 132 = 100001002
• Step 4 – Put S, E, and M together to form 32 -bit binary result 0 10000100100100000002 S E M
• Step 5 – Express in hexadecimal 0 10000100100100000002 = 0100 0010 0001 0010 0100 00002 = 4 2 1 2 4 0 0 016 Answer: 4212400016
Thank you
- Slides: 25