What are the differences between int, long, long long, and short? Between an unsigned and a signed type? Between a float and a double?
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:2| Question number:2.1
All Answers
total answers (1)
1.
need an explanation for this answer? contact us directly to get an explanation for this answer`int`, `long`, `long long` and `short`
Type | Minimum Size | Minimum Number Range
------------|--------------|--------------------------------
`
int
` | 16 bits | -32767 ~ +32767`long`
| 32 bits | -2,147,483,647 ~ +2,147,483,647`
long long
` | 64 bits | -9.22 * 10^18 ~ +9.22 * 10^18`
short
` | 16 bits | -32767 ~ +327672.
unsigned
andsigned
A
signed
type represents negative or positive numbers (including zero).An
unsigned
type represents only values greater than or equal to zero.For a type of same size, if the number range of
signed
type is `-n ~ +n`, then the number range ofunsigned
type is `0 ~ 2*n+1`.3. `
float
` and `double
`Type | Minimum Size
---------|----------------------------------------
`
float
` | 6 significant digits (usually 32 bits)`
double
` | 10 significant digits (usually 32 bits)