This preview shows pages 1–6. Sign up to view the full content.
The Integer Types
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document Objectives
•
Understand how the integer types are
used to represent numbers and non
numeric information
•
Understand how the type defines the
“interpretation” of the bits in a memory
location
•
Be ready for the pitfalls of C
Finiteness
•
Never forget that there are a finite number
of values any variable can take
–
k
bits means no more than 2
k
values
–
roughly 256
char
s, 64K
short
s, 4G
int
s
•
The “number line” is a circle!
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document Signed and Unsigned
•
Any of the integer types can be modified
with either signed or unsigned
–
Default is signed except for char which has no
default (it’s arbitrary)
•
Signed means “interpret as two’s
complement”
•
Unsigned means “interpret as binary”
Overflow
•
Overflow (or underflow) occurs when the
(mathematical) result of a computation cannot
be represented using the type defined
–
e.g., the result of “100 + 100” cannot be represented
in 8bit two’s complement
•
Puzzle: given the statement “z = x + y;” under
what circumstances will the wrong value be
calculated for z (i.e., when will it overflow)
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 07/24/2010 for the course EE 312 taught by Professor Shafer during the Spring '08 term at University of Texas at Austin.
 Spring '08
 Shafer

Click to edit the document details