W08-NumericDataTypes

W08-NumericDataTypes - 10/10/05 1 Data Types - Details...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 10/10/05 1 Data Types - Details 10/10/05 2 Numeric Types Learned So Far char small integer representing a symbol int positive/negative integers(10 digits) float positive/negative reals (6-7 digits) double positive/negative reals (15-16 digits) 10/10/05 3 Overflow Consider int i; i = 2147483647; printf("%d %d %d", i, i+1, i*i); What would you expect? 10/10/05 4 Whats going on here? Computers store only so many digits. When an operation creates more than they have, the higher digits are lost. Just like 5-digit odometer on a car. What comes after 99,999? -- 00,000 right? Same in computers -- next integer after the largest integer is the smallest integer 10/10/05 5 Binary Addition recall 1 + 1 = 10 (binary uses only 1s & 0s) 0001 (1 decimal) + 0101 (4 + 1 =5 decimal) 0110 (4 + 2 = 6 decimal) 1 10/10/05 6 Negation - 2s Complement To get negative, change all 1s to 0s and vice versa, then add 1 Take example of a signed 4-bit number decimal binary 1 0001-1 1110 + 1 = 1111 7 0111 (4+2+1)-7 1000 + 1 = 1001-8 1000 10/10/05...
View Full Document

Page1 / 5

W08-NumericDataTypes - 10/10/05 1 Data Types - Details...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online