DOC PREVIEW
IUPUI CSCI 23000 - Information Representation

This preview shows page 1-2-23-24 out of 24 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 24 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Slide 1Negative Numbers in BinarySlide 3Negative Numbers in Binary (cont.)Slide 5Three Representation of Signed IntegerSlide 7Fundamental Data TypeSlide 9Fractional NumbersSlide 11Fractional Numbers (cont.)Slide 13Slide 14Floating Point Number RepresentationSlide 16Slide 17Slide 18Slide 19Real Life Example: IEEE 754Slide 21Slide 22Slide 23AcknowledgementsDale RobertsDepartment of Computer and Information Science,School of Science, IUPUICSCI 230Information Representation: Negative and Floating Point Representation Dale Roberts, LecturerDale Roberts, [email protected]@cs.iupui.eduDale RobertsNegative Numbers in BinaryNegative Numbers in BinaryFour different representation schemes are used Four different representation schemes are used for negative numbersfor negative numbers1.1.Signed MagnitudeSigned MagnitudeLeft most bit (LMB) is the sign bit :0  positive (+)1  negative (-)Remaining bits hold absolute magnitudeExample: 210  0000 0010b-210  1000 0010bQ: 0000 0000 = ? 1000 0000 = ?Try, 1000 0100b = -410Dale Roberts2.2.One’s ComplementOne’s Complement–Left most bit is the sign bit :•0  positive (+)•1  negative (-)–The magnitude is ComplementedExample: 210  0 000 0010b-210  1 111 1101bExercise: try - 410 using 1’s ComplementQ: 0000 0000 = ?Q: 0000 0000 = ? 1111 1111 = ?1111 1111 = ?Solution: 410 = 0 000 0100 b-410 =111 1011 b1Dale RobertsNegative Numbers in Binary Negative Numbers in Binary (cont.)(cont.)3. 2’s Complement•Sign bit same as above•Magnitude is Complemented first and a “1” is added to the Complemented digitsExample: 210  0 000 0010b1’s Complement  1 111 1101b + 1 -210  1 111 1110b710 1’s Complement + 1 -710 Exercise: try -710 using 2’s Complement0000 0111b1111 1000b1111 1001bDale RobertsNegative Numbers in Binary Negative Numbers in Binary (cont.)(cont.)771010 = 0000 0111 = 0000 0111bb331010 = 0000 0011 = 0000 0011bb 1’s complement1’s complement 1111 1100 1111 1100bb 2’s complement2’s complement 1111 1101 1111 1101bb  -3 -310107+(-3) 7+(-3)  0000 01110000 0111 ++1111 11011111 1101Example: 7+(-3) [hint]: A – B = A + (~B) +11 1111 111 carryignore 1 0000 0100  0000 0100  410Dale RobertsValue RepresentationRepresentationSigned Magnitude 1's Complement 2's Complement0 00000 00010 00100 00110 01000 01010 01100 01110 10000 10010 10100 10110 11000 11010 11100 11111 00001 00011 00101 00111 01001 01011 01101 01111 10001 10011 10101 10111 11001 11011 11101 11110123456789101112131415-0-1-2-3-4-5-6-7-8-9-10-11-12-13-14-150123456789101112131415-15-14-13-12-11-10-9-8-7-6-5-4-3-2-1-00123456789101112131415-16-15-14-13-12-11-10-9-8-7-6-5-4-3-2-1Three Representation of Signed IntegerThree Representation of Signed IntegerDale RobertsNegative Numbers in Binary Negative Numbers in Binary (cont.)(cont.)4.4.Excess RepresentationExcess Representation–For a given fixed number of bits the range is remapped such that roughly half the numbers are negative and half are positive.Example: (as left)Excess – 8 notation for 4 bit numbersBinary value = 8 + excess-8 valueMSB can be used as a sign bit, butIf MSB =1, positive numberIf MSB =0, negative numberNumbers Binary ValueNotationExcess – 8 Value01234567891011121314150000000100100011010001010110011110001001101010111100110111101111-8-7-6-5-4-3-2-101234567Dale RobertsFundamental Data TypeFundamental Data Type2 byte unsigned (Default type is int)2 byte int0000 0000 0000 0000 (  0D)0000 0000 0000 0001 (  1D )0000 0000 0000 0010 (  2D )….0111 1111 1111 1111 (  32767D  215 -1)1000 0000 0000 0000 (  32768D  215)….1111 1111 1111 1111 ( 216 –1)1000 0000 0000 0000 (  -32768D  - 215 )1000 0000 0000 0001 (  -32767D  - 215 +1) ….1111 1111 1111 1110 (  - 2D )1111 1111 1111 1111 (  - 1D )0000 0000 0000 0000 (  0D )0000 0000 0000 0001 (  1D )0000 0000 0000 0010 (  2D ) ….0111 1111 1111 1111 (  32767D  215 -1)• With vs. without using sign bitWith vs. without using sign bitFor a 16 bit binary pattern:Dale RobertsFundamental Data TypeFundamental Data TypeFour Data TypesFour Data Types in Cin C (assume 2’s complement, byte machine)Data TypeData TypeAbbreviationAbbreviationSize (byte)Size (byte)RangeRangechar char 1 -128 ~ 127unsigned char 1 0 ~ 255intint 2 or 4 -215 ~ 215-1 or -231 ~ 231-1unsigned intunsigned2 or 4 0 ~ 65535 or 0 ~ 232-1short intshort2 -32768 ~ 32767unsigned short intunsigned short2 0 ~ 65535long intlong4 -231 ~ 231-1unsigned long intunsigned long4 0 ~ 232-1float 4double 8Note: 27 = 128, 215 =32768, 215 = 2147483648Complex and double complex are not availableDale RobertsFractional NumbersFractional NumbersExamplesExamples: : 456.78456.781010 = 4 x = 4 x 101022 + 5 x + 5 x 101011 + 6 x + 6 x 101000 + 7 x + 7 x 1010-1-1+8 x +8 x 1010-2-21011.111011.1122 = 1 x = 1 x 2233 + 0 x + 0 x 2222 + 1 x + 1 x 2211 + 1 x + 1 x 220 0 + 1 x + 1 x 22-1-1 + 1 x + 1 x 22-2-2= 8 + 0 + 2 + 1 + 1/2 + ¼= 8 + 0 + 2 + 1 + 1/2 + ¼= 11 + 0.5 + 0.25 = 11.75= 11 + 0.5 + 0.25 = 11.751010Conversion from binary number system to Conversion from binary number system to decimal systemdecimal systemExamplesExamples: : 111.11111.1122 = 1 x = 1 x 2222 + 1 x + 1 x 2211 + 1 x + 1 x 220 0 + 1 x + 1 x 22-1-1 + 1 x + 1 x 22-2-2= 4 + 2 + 1 + 1/2 + ¼ = 7.75= 4 + 2 + 1 + 1/2 + ¼ = 7.751010ExamplesExamples: 11.011: 11.01122 22 21 20 2-1 2-2 2-34 2 1 ½ ¼ 1/8 2 1 0 -1 -2 -3 x x x xDale RobertsConversion from decimal number system to binary systemConversion from decimal number system to binary systemExamplesExamples: : 7.757.751010 = (?) = (?)221.1.Conversion of the Conversion of the integerinteger part: same as before – repeated division by 2 part: same as before – repeated division by 27 / 2 = 3 (Q), 7 / 2 = 3 (Q), 11 (R) (R)  3 / 2 = 1 (Q), 3 / 2 = 1 (Q), 11 (R) (R)  1 / 2 = 0 (Q), 1 / 2 = 0 (Q), 11 (R) 7 (R) 710 10 == 111 111222.2.Conversion of the Conversion of the fractional fractional part: perform a repeated multiplication by 2 and extract the integer part of part: perform a repeated multiplication by 2 and extract the integer part of the resultthe result0.75 x 2 =0.75 x 2 =11..50 50


View Full Document

IUPUI CSCI 23000 - Information Representation

Download Information Representation
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Information Representation and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Information Representation 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?