Skip to content

Instantly share code, notes, and snippets.

@kgashok
Created November 26, 2016 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgashok/6bafac599f1a8bdb33d9e43574e75dff to your computer and use it in GitHub Desktop.
Save kgashok/6bafac599f1a8bdb33d9e43574e75dff to your computer and use it in GitHub Desktop.
CheatSheetForSizeOfVariablesInC.md
### Size and Range of Variable Types in C
For a **16-bit** processor, here's the tabulation :
|Modifier | Variable Type | sizeof | Range | Precision |
|-----------|-----------|-----------------|:-----------|:-------|
|unsigned | char | 1 | 0 to 256
| | char | 1 | -127 to 127
|short |int | 2 | `–32,767` to `32,767` |
| |int | 2 | |
|unsigned |int | 2 | 0 to `65,535`
|long |int | 4 |`–2,147,483,647` to `2,147,483,647`|
|unsigned long |int | 4 |0 to `4,294,967,295`|
|long long |int | 8 | `-(2^63 –1)` to `(2^63 –1)`
|unsigned long long | int | 8 | 0 to 2^(8bits*8bytes -1) = `2^64 - 1`
| | float | 4 | 1E-37 to 1E+37 | upto 6-9 significant digits e.g. `3.141592` or `3.14159`?|
| | double | 8 | | upto 15-17 significant digits
| long | double | 10 | 1E-37 to 1E+37 | precision to 10 digits, e.g. `3.1415926535` or `3.141592653`?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment