
CS485G Spring 2015 5
6. What is the largest signed integer you can store in 16 bits? (Answer:
2
15
− 1 = 32767)
7. How many bits do you need to store 4893? It’s about 4 × 10
3
, so
about 12 bits. (The right answer is 13 bits, but in a 2’s complement
representation, at least 14 bits.)
6 C types and their sizes
1. Unfortunately, C declarations are machine-specific. Here is the size
in bytes of various declarations.
C declaration x86 x86-64
char 1 1
short 2 2
int 4 4
long 4 8 !
long long 8 8
float 4 4
double 8 8
long double 12 16 !
pointer 4 8 !
7 Byte ordering
1. If a word has more than one byte, what is the order?
2. Example: 19088743 = 01234567
16
3. Big-endian: Least significant byte has the highest address. (Sun,
PPC, Mac, Internet). The bytes, in order, are 0x01, 0x23, 0x45, 0x67.
4. Little-endian: Least significant byte has the lowest address. (x86).
The bytes, in order, are 0x67, 0x45, 0x23, 0x01.
5. You can use the od program to show a file in bytes, characters, inte-
gers, ...
6. Lecture 4, 1/23/2015 Lab 2
7. Lecture 5, 1/26/2015
Kommentare zu diesen Handbüchern