Upcoming SlideShare
×

# Chapter 02 Data Types

3,258 views

Published on

1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
3,258
On SlideShare
0
From Embeds
0
Number of Embeds
490
Actions
Shares
0
96
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Chapter 02 Data Types

1. 1. Chapter 2 - Data Types
2. 2. Today… <ul><li>Unit 1 slides and homework in JFSB B115 </li></ul><ul><li>Problems with CCE on Talmage Window’s machines… </li></ul><ul><ul><li>Drivers have to be installed with administrator privileges </li></ul></ul><ul><ul><li>Ready shortly… </li></ul></ul><ul><li>Help Sessions begin Monday @4:00 pm </li></ul><ul><li>Reading Assignments on-line under the Schedule Tab </li></ul><ul><li>Concerns or problems?? </li></ul>
3. 3. Concepts to Learn… <ul><li>Binary Digital System </li></ul><ul><li>Data Types </li></ul><ul><li>Conversions </li></ul><ul><li>Binary Arithmetic </li></ul><ul><li>Overflow </li></ul><ul><li>Logical Operations </li></ul><ul><li>Floating Point </li></ul><ul><li>Hexadecimal Numbers </li></ul><ul><li>ASCII Characters </li></ul>
4. 4. What are Decimal Numbers? <ul><li>“Decimal” means that we have ten digits to use in our representation </li></ul><ul><ul><li>the symbols 0 through 9 </li></ul></ul><ul><li>What is 3,546? </li></ul><ul><ul><li>3 thousands + 5 hundreds + 4 tens + 6 ones . </li></ul></ul><ul><ul><li>3,546 10 = 3  10 3 + 5  10 2 + 4  10 1 + 6  10 0 </li></ul></ul><ul><li>How about negative numbers? </li></ul><ul><ul><li>Use two more symbols to distinguish positive and negative, namely, + and -. </li></ul></ul>Digital Binary System
5. 5. What are Binary Numbers? <ul><li>“Binary” means that we have two digits to use in our representation </li></ul><ul><ul><li>the symbols 0 and 1 </li></ul></ul><ul><li>What is 1011? </li></ul><ul><ul><li>1 eights + 0 fours + 1 twos + 1 ones </li></ul></ul><ul><ul><li>1011 2 = 1  2 3 + 0  2 2 + 1  2 1 + 1  2 0 </li></ul></ul><ul><li>How about negative numbers? </li></ul><ul><ul><li>We don’t want to add additional symbols </li></ul></ul><ul><ul><li>So… </li></ul></ul>Digital Binary System
6. 6. Binary Digital System <ul><li>Binary (base 2) because there are two states, 0 and 1. </li></ul><ul><li>Digital because there are a finite number of symbols. </li></ul><ul><li>Basic unit of information is the binary digit , or bit . </li></ul><ul><li>Bit values are represented by various physical means. </li></ul><ul><ul><li>Voltages </li></ul></ul><ul><ul><li>Residual magnetism </li></ul></ul><ul><ul><li>Light </li></ul></ul><ul><ul><li>Electromagnetic Radiation </li></ul></ul><ul><ul><li>Polarization </li></ul></ul><ul><li>Values with more than two states require multiple bits. </li></ul><ul><ul><li>A collection of 2 bits has 4 possible states: 00, 01, 10, 11 </li></ul></ul><ul><ul><li>A collection of 3 bits has 8 possible states: 000, 001, 010, 011, 100, 101, 110, 111 </li></ul></ul><ul><ul><li>A collection of n bits has 2 n possible states. </li></ul></ul>Digital Binary System
7. 7. Electronic Representation of a Bit <ul><li>Relies only on approximate physical values. </li></ul><ul><ul><li>A logical ‘1’ is a relatively high voltage (2.4V - 5V). </li></ul></ul><ul><ul><li>A logical ‘0’ is a relatively low voltage (0V - 1V). </li></ul></ul><ul><li>Analog processing relies on exact values which are affected by temperature, age, etc. </li></ul><ul><ul><li>Analog values are never quite the same. </li></ul></ul><ul><ul><li>Each time you play a vinyl album, it will sound a bit different. </li></ul></ul><ul><ul><li>CDs sound the same no matter how many times you play them. </li></ul></ul>Digital Binary System
8. 8. The Power of the Bit… <ul><li>Bits rely on approximate physical values that are not affected by age, temperature, etc. </li></ul><ul><ul><li>Music that never degrades. </li></ul></ul><ul><ul><li>Pictures that never get dusty or scratched. </li></ul></ul><ul><li>By using groups of bits, we can achieve high precision. </li></ul><ul><ul><li>8 bits => each bit pattern represents 1/256. </li></ul></ul><ul><ul><li>16 bits => each bit pattern represents 1/65,536 </li></ul></ul><ul><ul><li>32 bits => each bit pattern represents 1/4,294,967,296 </li></ul></ul><ul><ul><li>64 bits => each bit pattern represents 1/18,446,744,073,709,550,000 </li></ul></ul><ul><li>Disadvantage: bits only represent discrete values </li></ul><ul><li>Digital = Discrete </li></ul>Digital Binary System
9. 9. Binary Nomenclature <ul><li>Binary Digit: 0 or 1 </li></ul><ul><li>Bit (short for binary digit): A single binary digit </li></ul><ul><li>LSB (least significant bit): The rightmost bit </li></ul><ul><li>MSB (most significant bit): The leftmost bit </li></ul><ul><li>Data sizes </li></ul><ul><ul><li>1 Nibble (or nybble) = 4 bits </li></ul></ul><ul><ul><li>1 Byte = 2 nibbles = 8 bits </li></ul></ul><ul><ul><li>1 Kilobyte (KB) = 1024 bytes </li></ul></ul><ul><ul><li>1 Megabyte (MB) = 1024 kilobytes = 1,048,576 bytes </li></ul></ul><ul><ul><li>1 Gigabyte (GB) = 1024 megabytes = 1,073,741,824 bytes </li></ul></ul>Digital Binary System
10. 10. What Kinds of Data? <ul><li>All kinds… </li></ul><ul><ul><li>Numbers – signed, unsigned, integers, floating point, complex, rational, irrational, … </li></ul></ul><ul><ul><li>Text – characters, strings, … </li></ul></ul><ul><ul><li>Images – pixels, colors, shapes, … </li></ul></ul><ul><ul><li>Sound – pitch, amplitude, … </li></ul></ul><ul><ul><li>Logical – true / false, open / closed, on / off, … </li></ul></ul><ul><ul><li>Instructions – programs, … </li></ul></ul><ul><ul><li>… </li></ul></ul><ul><li>Data type: </li></ul><ul><ul><li>representation and operations within the computer </li></ul></ul><ul><li>We’ll start with numbers… </li></ul>Data Types
11. 11. Some Important Data Types <ul><li>Unsigned integers </li></ul><ul><ul><li>only non-negative numbers </li></ul></ul><ul><ul><li>0, 1, 2, 3, 4, … </li></ul></ul><ul><li>Signed integers </li></ul><ul><ul><li>negative, zero, positive numbers </li></ul></ul><ul><ul><li>… , -3, -2, -1, 0, 1, 2, 3, … </li></ul></ul><ul><li>Floating point numbers </li></ul><ul><ul><li>numbers with decimal point </li></ul></ul><ul><ul><li>PI = 3.14159 x 10 0 </li></ul></ul><ul><li>Characters </li></ul><ul><ul><li>8-bit, unsigned integers </li></ul></ul><ul><ul><li>‘ 0’, ‘1’, ‘2’, … , ‘a’, ‘b’, ‘c’, … , ‘A’, ‘B’, ‘C’, … , ‘@’, ‘#’, </li></ul></ul>Data Types
12. 12. Unsigned Integers <ul><li>What do these unsigned binary numbers represent? </li></ul>3x100 + 2x10 + 9x1 = 329 1x4 + 0x2 + 1x1 = 5 0000 0110 1111 1010 0001 1000 0111 1100 1011 1001 <ul><li>Weighted positional notation </li></ul><ul><ul><li>“ 3” is worth 300, because of its position, while “9” is only worth 9 </li></ul></ul>Data Types 329 10 2 10 1 10 0 101 2 2 2 1 2 0 most significant least significant
13. 13. Unsigned Integers (continued…) Data Types 7 1 1 1 6 0 1 1 5 1 0 1 4 0 0 1 3 1 1 0 2 0 1 0 1 1 0 0 0 0 0 0 2 0 2 1 2 2
14. 14. Unsigned Binary Arithmetic <ul><li>Base 2 addition – just like base 10! </li></ul><ul><ul><li>add from right to left, propagating carry </li></ul></ul>10010 10010 1111 + 1001 + 1011 + 1 11011 11101 10000 10111 + 111 Subtraction, multiplication, division,… 0 1 1 1 1 Data Types carry
15. 15. Signed Integers <ul><li>With n bits, we have 2 n distinct values. </li></ul><ul><ul><li>assign about half to positive integers (1 through 2 n-1 ) and about half to negative (- 2 n-1 through -1) </li></ul></ul><ul><ul><li>that leaves two values: one for 0, and one extra </li></ul></ul><ul><li>Positive integers </li></ul><ul><ul><li>just like unsigned – zero in most significant (MS) bit 00101 = 5 </li></ul></ul><ul><li>Negative integers </li></ul><ul><ul><li>sign-magnitude – set MS bit to show negative 10101 = -5 </li></ul></ul><ul><ul><li>one’s complement – flip every bit to represent negative 11010 = -5 </li></ul></ul><ul><ul><li>MS bit indicates sign: 0=positive, 1=negative </li></ul></ul>Data Types
16. 16. Sign-Magnitude Integers <ul><li>Representations </li></ul><ul><ul><li>01111 binary => 15 decimal </li></ul></ul><ul><ul><li>11111 => -15 </li></ul></ul><ul><ul><li>00000 => 0 </li></ul></ul><ul><ul><li>10000 => -0 </li></ul></ul><ul><li>Problems </li></ul><ul><ul><li>Difficult addition/subtraction </li></ul></ul><ul><ul><ul><li>check signs </li></ul></ul></ul><ul><ul><ul><li>convert to positive </li></ul></ul></ul><ul><ul><ul><li>use adder or subtractor as required </li></ul></ul></ul>The left-bit encodes the sign: 0 = + 1 =  Data Types
17. 17. 1’s Complement Integers <ul><li>Representations </li></ul><ul><ul><li>00110 binary => 6 decimal </li></ul></ul><ul><ul><li>11001 => -6 </li></ul></ul><ul><ul><li>00000 => 0 </li></ul></ul><ul><ul><li>11111 => -0 </li></ul></ul><ul><li>Problem </li></ul><ul><ul><li>Difficult addition/subtraction </li></ul></ul><ul><ul><ul><li>no need to check signs as before </li></ul></ul></ul><ul><ul><ul><li>cumbersome logic circuits </li></ul></ul></ul><ul><ul><ul><ul><li>end-around-carry </li></ul></ul></ul></ul>To negate a number, Invert it, bit-by-bit. The left-bit still encodes the sign: 0 = + 1 =  Data Types
18. 18. 2’s Complement <ul><li>Problems with sign-magnitude and 1’s complement </li></ul><ul><ul><li>two representations of zero (+0 and –0) </li></ul></ul><ul><ul><li>arithmetic circuits are complex </li></ul></ul><ul><ul><ul><li>How to add two sign-magnitude numbers? </li></ul></ul></ul><ul><ul><ul><li>e.g., try 2 + (-3) </li></ul></ul></ul><ul><ul><ul><li>How to add to one’s complement numbers? </li></ul></ul></ul><ul><ul><ul><li>e.g., try 4 + (-3) </li></ul></ul></ul><ul><li>Two’s complement representation developed to make circuits easy for arithmetic. </li></ul>Data Types
19. 19. 2’s Complement (continued…) <ul><li>Simplifies logic circuit construction because </li></ul><ul><ul><li>addition and subtraction are always done using the same circuitry. </li></ul></ul><ul><ul><li>there is no need to check signs and convert. </li></ul></ul><ul><ul><li>operations are done same way as in decimal </li></ul></ul><ul><ul><ul><li>right to left </li></ul></ul></ul><ul><ul><ul><li>with carries and borrows </li></ul></ul></ul><ul><li>Bottom line: simpler hardware units! </li></ul>Data Types
20. 20. 2’s Complement (continued…) <ul><li>If number is positive or zero, </li></ul><ul><ul><li>normal binary representation </li></ul></ul><ul><li>If number is negative, </li></ul><ul><ul><li>start with positive number </li></ul></ul><ul><ul><li>flip every bit (i.e., take the one’s complement) </li></ul></ul><ul><ul><li>then add one </li></ul></ul>00101 (5) 01001 (9) 11010 (1’s comp) (1’s comp) + 1 + 1 11011 (-5) (-9) 10110 10111 Data Types
21. 21. 2’s Complement (continued…) <ul><li>Positional number representation with a twist </li></ul><ul><ul><li>the most significant (left-most) digit has a negative weight </li></ul></ul><ul><ul><li>n -bits represent numbers in the range  2 n  1 … 2 n  1  1 </li></ul></ul><ul><li>What are these? </li></ul>0110 = 2 2 + 2 1 = 6 1110 = -2 3 + 2 2 + 2 1 = -2 0000 0110 1111 1010 0001 1000 0111 1100 1011 1001 Data Types
22. 22. 2’s Complement Shortcut <ul><li>To take the two’s complement of a number: </li></ul><ul><ul><li>copy bits from right to left until (and including) the first “1” </li></ul></ul><ul><ul><li>flip remaining bits to the left </li></ul></ul>011010000 011010000 100101111 (1’s comp) + 1 100110000 100110000 (copy) (flip) Data Types
23. 23. 2’s Complement Negation <ul><li>To negate a number, invert all the bits and add 1 </li></ul>6 1010 7 1001 0 0000 -1 0001 4 1100 -8 1000 (??) Data Types
24. 24. Quiz 00100110 (unsigned int) + 10001101 (signed magnitude) + 11111101 (1’s complement) + 00001101 (2’s complement) + 10111101 (2’s complement) (decimal)
25. 25. Quiz 00100110 (unsigned int) + 10001101 (signed magnitude) (unsigned int) + 11111101 (1’s complement) (signed int) + 00001101 (2’s complement) (2’s complement) + 10111101 (2’s complement) Decimal 00011001 00010111 00100100 -31 11100001 (2’s complement) 11100000 (1’s complement) 10011111 (signed magnitude) 38 + -13 25 + -2 23 + 13 36 + -67 -31
26. 26. <ul><li>Continually divide the number by 2 and track the remainders. </li></ul>Decimal to Binary Conversion 1  2 5 + 0  2 4 + 1  2 3 + 0  2 2 + 1  2 1 + 1  2 0 32 + 0 + 8 + 0 + 2 + 1 = 43 43 <ul><li>For negative numbers, do above for positive number and negate result </li></ul>Conversions 2 2 2 2 2 2 5 R 0 0 2 R 1 1 21 R 1 1 10 R 1 1 1 R 0 0 0 R 1 1
27. 27. Decimal to Binary Conversion 0101 0110 01111011 00100011 11011101 01111101111 Conversions
28. 28. Sign-Extension in 2’s Complement <ul><li>You can make a number wider by simply replicating its leftmost bit as desired. </li></ul>0110 = 000000000000000110 = 1111 = 11111111111111111 = 1 = 6 6 -1 -1 -1 <ul><li>What do these represent? </li></ul>Conversions
29. 29. Word Sizes <ul><li>In the preceding slides, every bit pattern was a different length (15 was represented as 01111). </li></ul><ul><li>Every real computer has a base word size </li></ul><ul><ul><li>our machine (MPS430) is 16-bits </li></ul></ul><ul><li>Memory fetches are word-by-word </li></ul><ul><ul><li>even if you only want 8 bits (a byte) </li></ul></ul><ul><li>Instructions are packed into words </li></ul><ul><li>Numeric representations are word-sized </li></ul><ul><ul><li>15 is represented as 0000000000001111 </li></ul></ul>Conversions
30. 30. Rules of Binary Addition <ul><li>Rules of Binary Addition </li></ul><ul><ul><li>0 + 0 = 0 </li></ul></ul><ul><ul><li>0 + 1 = 1 </li></ul></ul><ul><ul><li>1 + 0 = 1 </li></ul></ul><ul><ul><li>1 + 1 = 0, with carry </li></ul></ul><ul><li>Two's complement addition follows the same rules as binary addition </li></ul><ul><li>Two's complement subtraction is the binary addition of the minuend to the 2's complement of the subtrahend </li></ul><ul><ul><li>adding a negative number is the same as subtracting a positive one </li></ul></ul>Binary Arithmetic 5 + (-3) = 2 0000 0101 = +5 + 1111 1101 = -3 --------- -- 0000 0010 = +2
31. 31. Adding 2’s Complement Integers <ul><li>Issues </li></ul><ul><ul><li>Overflow: the result cannot be represented by the number of bits available </li></ul></ul>c 00110 +00101 01011 b1 00110 -00101 00001 0110 +0101 1011 Hmmm. 6 + 5  -5. Obviously something went wrong. This is a case of overflow . You can tell there is a problem - a positive plus a positive cannot give a negative. Binary Arithmetic
32. 32. Overflow Revisited <ul><li>Overflow = the result doesn’t fit in the capacity of the representation </li></ul><ul><li>ALU’s are designed to detect overflow </li></ul><ul><li>It’s really quite simple </li></ul><ul><ul><li>if the carry in to the most significant position (MSB) is different from the carry out from the most significant position (MSB), then overflow occurred. </li></ul></ul><ul><li>Generally, overflows represented in CPU status bit </li></ul>Overflow
33. 33. Logical Operations on Bits A B AND 0 0 0 0 1 0 1 0 0 1 1 1 A B OR 0 0 0 0 1 1 1 0 1 1 1 1 A NOT 0 1 1 0 a = 001100101 b = 110010100 a AND b = ? a OR b = ? NOT a = ? A XOR b = ? a AND b = 000000100 a = 001100101 b = 110010100 a OR b = 111110101 NOT a = 110011010 A B XOR 0 0 0 0 1 1 1 0 1 1 1 0 A XOR b = 111110001 Logical Operations
34. 34. Examples of Logical Operations <ul><li>AND </li></ul><ul><ul><li>useful for clearing bits </li></ul></ul><ul><ul><ul><li>AND with zero = 0 </li></ul></ul></ul><ul><ul><ul><li>AND with one = no change </li></ul></ul></ul><ul><li>OR </li></ul><ul><ul><li>useful for setting bits </li></ul></ul><ul><ul><ul><li>OR with zero = no change </li></ul></ul></ul><ul><ul><ul><li>OR with one = 1 </li></ul></ul></ul><ul><li>NOT </li></ul><ul><ul><li>unary operation -- one argument </li></ul></ul><ul><ul><li>flips every bit </li></ul></ul>11000101 AND 00001111 00000101 11000101 OR 00001111 11001111 NOT 11000101 00111010 Logical Operations
35. 35. Floating Point Numbers <ul><li>Binary scientific notation </li></ul><ul><li>32-bit floating point </li></ul><ul><li>Exponent is biased </li></ul><ul><li>Implied leading 1 in mantissa </li></ul>s exponent mantissa 1 8 23 Floating Point
36. 36. Floating Point Numbers <ul><li>Why the leading implied 1? </li></ul><ul><ul><li>Always normalize after an operation </li></ul></ul><ul><ul><ul><li>shift mantissa until leading digit is a 1 </li></ul></ul></ul><ul><ul><ul><li>can assume it is always there, so don’t store it </li></ul></ul></ul><ul><li>Why the biased exponent? </li></ul><ul><ul><li>To avoid signed exponent representations </li></ul></ul>s exponent mantissa 1 8 23 Floating Point
37. 37. Floating Point Numbers <ul><li>What does this represent? </li></ul>Mantissa is to be interpreted as 1 .1 This is 2 0 + 2 -1 = 1 + 1/2 = 1.5 The final number is 1.5 x 2 1 = 3 0 10000000 10000000000000000000000 Floating Point Positive number Exponent is 128 which means the real exponent is 1
38. 38. Floating Point Numbers <ul><li>What does this represent? </li></ul>The final number is -1.65625 x 2 2 = -6.625 1 10000001 10101000000000000000000 Floating Point Negative number Exponent is 129 which means the real exponent is 2 Mantissa is to be interpreted as 1 .10101 This is 2 0 + 2 -1 + 2 -3 + 2 -5 = 1 + 1/2 + 1/8 + 1/32 = 1.65625
39. 39. Hexadecimal Notation <ul><li>Binary is hard to read and write by hand </li></ul><ul><li>Hexadecimal is a common alternative </li></ul><ul><ul><li>16 digits are 0123456789ABCDEF </li></ul></ul>0100 0111 1000 1111 = 0x478F 1101 1110 1010 1101 = 0xDEAD 1011 1110 1110 1111 = 0xBEEF 1010 0101 1010 0101 = 0xA5A5 Binary Hex 0000 0 0001 1 0010 2 0011 3 0100 4 0101 5 0110 6 0111 7 1000 8 1001 9 1010 A 1011 B 1100 C 1101 D 1110 E 1111 F <ul><li>Separate binary code into groups of 4 bits (starting from the right) </li></ul><ul><li>Translate each group into a single hex digit </li></ul>Hexadecimal 0x is a common prefix for writing numbers which means hexadecimal
40. 40. Binary to Hex Conversion <ul><li>Every four bits is a hex digit. </li></ul><ul><ul><li>start grouping from right-hand side </li></ul></ul>011101010001111010011010111 7 D 4 F 8 A 3 This is not a new machine representation, just a convenient way to write the number. Hexadecimal
41. 41. Decimal to Hex Conversion <ul><li>Positive numbers </li></ul><ul><ul><li>start with empty result </li></ul></ul><ul><ul><li>next digit to prepend is number modulo 16 </li></ul></ul><ul><ul><li>divide number by 16, throw away fractional part </li></ul></ul><ul><ul><li>if new number is non-zero, go back to  else you are done </li></ul></ul><ul><li>Negative numbers </li></ul><ul><ul><li>do above for positive version of number and negate result. </li></ul></ul>Hexadecimal
42. 42. Decimal to Hex Examples 12 decimal = 1100 = 0xc 21 decimal = 0001 0101 = 0x15 55 decimal = 0011 0111 = 0x37 256 decimal = 0001 0000 0000 = 0x100 47 decimal = 0010 1111 = 0x2f 3 decimal = 0011 = 0x3 127 decimal = 0111 1111 = 0x7f 1029 decimal = 0100 0000 0101 = 0x405 Hexadecimal
43. 43. ASCII Codes <ul><li>How do you represent characters? ‘A’ </li></ul><ul><li>ASCII is a set of standard 8-bit, unsigned integers (codes) </li></ul><ul><ul><li>' ' = 32, '0' = 48, '1' = 49, 'A' = 65, 'B' = 66 </li></ul></ul><ul><li>Zero-extended to word size </li></ul><ul><li>To convert an integer digit to ASCII character, add 48 (=‘0’) </li></ul><ul><ul><li>1 + 48 = 49 => ‘1’ </li></ul></ul>ASCII Characters
44. 44. ASCII Characters 0 1 2 3 4 5 6 7 8 9 a b c d e f 0 1 2 3 4 5 6 7 8-9 a-f More controls More symbols ASCII Characters DEL o _ O ? / US SI ~ n ^ N > . RS SO } m ] M = - GS CR | l L < , FS FF { k [ K ; + ESC VT z j Z J : * SUB LF y i Y I 9 ) EM HT x h X H 8 ( CAN BS w g W G 7 ‘ ETB BEL v f V F 6 & SYN ACK u e U E 5 % NAK ENQ t d T D 4 \$ DC4 EOT s c S C 3 # DC3 ETX r b R B 2 “ DC2 STX q a Q A 1 ! DC1 SOH p ` P @ 0 SP DLE NUL
45. 45. Properties of ASCII Code <ul><li>What is relationship between a decimal digit ('0', '1', …) and its ASCII code? </li></ul><ul><li>What is the difference between an upper-case letter ('A', 'B', …) and its lower-case equivalent ('a', 'b', …)? </li></ul><ul><li>Given two ASCII characters, how do we tell which comes first in alphabetical order? </li></ul><ul><li>What is significant about the first 32 ASCII codes? </li></ul><ul><li>Are 128 characters enough? (http://www.unicode.org/) </li></ul>ASCII Characters
46. 46. Displaying Characters ASCII Characters 48 Decimal 58 Decimal 116 Decimal 53 Decimal
47. 47. MSP430 Data Types <ul><li>Words and bytes are supported directly by the Instruction Set Architecture. </li></ul><ul><ul><li>add.b </li></ul></ul><ul><ul><li>add.w </li></ul></ul><ul><li>8-bit and 16-bit 2’s complement signed integers </li></ul><ul><li>Other data types are supported by interpreting variable length values as logical, text, fixed-point, etc., in the software that we write. </li></ul>Data Types
48. 48. Review: Representation <ul><li>Everything is stored in memory as one’s and zero’s </li></ul><ul><ul><li>integers, floating point numbers, characters </li></ul></ul><ul><ul><li>program code </li></ul></ul><ul><li>Data Type = Representation + Operations </li></ul><ul><li>You can’t tell what is what just by looking at the binary representation </li></ul><ul><ul><li>memory could have multiple meanings </li></ul></ul><ul><ul><li>it is possible to execute your Word document </li></ul></ul>Review
49. 49. Review: Numbers… 7 6 5 4 3 2 1 0 -1 -2 -3 -4 111 110 101 100 011 010 001 000 011 010 001 000, 100 101 110 111 011 010 001 000, 111 110 101 100 011 010 001 000 111 110 101 100 Un-signed Signed Magnitude 1’s Complement 2’s Complement Range: 0 to 7 -3 to 3 -3 to 3 -4 to 3 Review
50. 51. ASCII Characters ASCII Characters