Systems 1 Integers - University of Texas at Austin
Systems 1
Integers
Topics
Numeric Encodings
Unsigned & Twos complement
Programming Implications
C promotion rules
Basic operations
Addition, negation, multiplication
Programming Implications
Consequences of overflow Using shifts to perform power-of-2 multiply/divide
Encoding Integers
Unsigned
Twos Complement
w "1
B2U(X ) = # xi !2 i i=0
w!2
B2T (X ) = # ! xw!1 "2w!1 + xi "2i i= 0
short int x = 15213; short int y = -15213;
C short 2 bytes long
Sign Bit
Decimal Hex
Binary
x
15213 3B 6D 00111011 01101101
y
-15213 C4 93 11000100 10010011
Sign Bit
For 2s complement, most significant bit indicates sign
0 for nonnegative 1 for negative
2
Encoding Example (Cont.)
x =
15213: 00111011 01101101
y =
-15213: 11000100 10010011
Weight
15213
-15213
1
1
1
1
1
2
0
0
1
2
4
1
4
0
0
8
1
8
0
0
16
0
0
1
16
32
1
32
0
0
64
1
64
0
0
128
0
0
1
128
256
1
256
0
0
512
1
512
0
0
1024
0
0
1 1024
2048
1 2048
0
0
4096
1 4096
0
0
8192
1 8192
0
0
16384
0
0
1 16384
-32768
0
0
1 -32768
Sum
15213
-15213
3
Numeric Ranges
Unsigned Values UMin = 0
000...0
UMax = 2w ? 1
111...1
Values for W = 16
UMax TMax TMin -1 0
Decimal 65535 32767 -32768 -1 0
Twos Complement Values TMin = ?2w?1
100...0
TMax = 2w?1 ? 1
011...1
Other Values Minus 1
111...1
Hex FF FF 7F FF 80 00 FF FF 00 00
Binary 11111111 11111111 01111111 11111111 10000000 00000000 11111111 11111111 00000000 00000000
4
Values for Different Word Sizes
8 UMax 255 TMax 127 TMin -128
16 65,535 32,767 -32,768
W 32 4,294,967,295 2,147,483,647 -2,147,483,648
64 18,446,744,073,709,551,615
9,223,372,036,854,775,807 -9,223,372,036,854,775,808
Observations
|TMin | = TMax + 1
Asymmetric range
UMax = 2 * TMax + 1
C Programming
#include
K&R App. B11
Declares constants, e.g.,
ULONG_MAX LONG_MAX LONG_MIN
Values platform-specific
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- cs 107 lecture 2 integer representations
- c reference card ansi constants flow of control program
- signed and unsigned integers in c example
- exchange wikileaks
- sample problems for midterm exam
- eecs 213 midterm exam northwestern university
- security coding module integer error you can t count
- understanding integer overflow in c c university of utah
- defensive programming part 1 types conditionals assertions
- bits bytes and integers
Related searches
- university of texas at austin
- university of texas austin tx
- university of texas at austin online
- university of texas at dallas graduate school
- university of texas austin graduate
- university of texas at dallas housing
- university of texas at austin online masters
- university of texas austin graduate school
- university of texas austin nursing
- university of texas at austin athletics
- university of texas austin certificate
- university of texas austin tuition cost