Q:

What are the differences between int, long, long long, and short? Between an unsigned and a signed type? Between a float and a double?

0

What are the differences between int, long, long long, and short? Between an unsigned and a signed type? Between a float and a double?

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

1. `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 ~ +32767

2. unsigned and signed

  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 of unsigned 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)

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now