{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# Lecture 2 - Th The University of Texas at Dallas Erik...

This preview shows pages 1–5. Sign up to view the full content.

Erik Jonsson School of Engineering and Th U i it f T t D ll Computer Science The University of Texas at Dallas Easier Ways to Express Binary Numbers Unfortunately, we were not born with 4 (or 8!) fingers per hand. The reason is that it is relatively difficult to convert binary numbers to decimal, and vice-versa. However, converting hexadecimal (base-16) numbers back and forth to binary is very easy (the octal, or base-8, number system was also used at one time). 4 Since 16 = 2 , it is very easy to convert a binary number of any length into hexadecimal form, and vice-versa: 0 16 = 0 10 = 0000 2 4 16 = 4 10 = 0100 2 8 16 = 8 10 = 1000 2 C 16 = 12 10 = 1100 2 1 1 0001 5 5 0101 9 9 1001 D 13 1101 16 = 1 10 = 2 16 = 5 10 = 2 16 = 10 = 2 16 = 13 10 = 2 2 16 = 2 10 = 0010 2 6 16 = 6 10 = 0110 2 A 16 = 10 10 = 1010 2 E 16 = 14 10 = 1110 2 3 16 = 3 10 = 0011 2 7 16 = 7 10 = 0111 2 B 16 = 11 10 = 1011 2 F 16 = 15 10 = 1111 2 The letters that stand for hexadecimal numbers above 9 can be upper © N. B. Dodge 9/09 1 Lecture #2: Signed Binary Numbers and Binary Codes The letters that stand for hexadecimal numbers above 9 can be upper or lower case – both are used. Note that one nibble = one hex digit.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Erik Jonsson School of Engineering and Th U i it f T t D ll Computer Science The University of Texas at Dallas Binary-Hexadecimal Since 2 4 = 16, each hex digit effectively represents the same numeric count as four binary digits. A th t thi i th t l i h b i th Another way to say this is that one column in a hex number is the same as four columns of a binary number. 0 1 2 1 2 100101011011 01111010 16 16 16 16 -1 16 -2 = 0x 95B 7A* 100101011011.01111010 2 5 2 4 2 6 2 7 2 9 2 8 2 10 2 11 2 1 2 0 2 2 2 3 2 -3 2 -4 2 -2 2 -1 2 -7 2 -8 2 -6 2 -5 0x 95B.7A *Note: The “0x” prefix before a number signifies “hexadecimal ” © N. B. Dodge 9/09 2 Lecture #2: Signed Binary Numbers and Binary Codes “hexadecimal .”
Erik Jonsson School of Engineering and Th U i it f T t D ll Computer Science The University of Texas at Dallas Hexadecimal-Binary Conversion Most computers process 32 or 64 bits at a time. In a 32-bit computer such as we will study, each data element in the computer memory (or “word”) is 32 bits. computer memory (or word ) is 32 bits. Example: 01111000101001011010111110111110 Separate into 4-bit groups, starting at the right: 0111 1000 1010 0101 1010 1111 1011 1110 Converting: 0111 2 =7 16 , 1000 2 =8 16 , 1010 2 =A 16 , 0101 2 =5 16 , 1010 2 =A 16 , 1111 2 =F 16 , 1011 2 =B 16 , 1110 2 =E 16 Or, 01111000101001011010111110111110 = 0x 78A5AFBE A th l Another example: Grouping: 1001011100.11110011 2 = 10 0101 1100 . 1111 0011 = (00)10 0101 1100 . 1111 0011 = 2 5 C F 3 = 0x 25C F3 © N. B. Dodge 9/09 3 Lecture #2: Signed Binary Numbers and Binary Codes = 2 5 C . F 3 = 0x 25C.F3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document