General Programming Cheatsheet
TODO: There isn’t a lot of content here yet since I’m only filling it out as I need it.Fixed-Width Integers
This table assumes you’re programming in C on a common computer architecture. “Minimum C Type” refers to C type in which the language specification requires this size to be the minimum. To keep it simple, I only include an easily recognizable subset.
Description | Minimum | Maximum | Minimum C Type | ||||
---|---|---|---|---|---|---|---|
Unsigned 8-bit (1 bytes) | 0 | 255 | unsigned char | ||||
Unsigned 16-bit (2 bytes) | 0 | 65535 | unsigned short | unsigned int | ||||
Unsigned 32-bit (4 bytes) | 0 | 4294967295 | unsigned long | ||||
Unsigned 64-bit (8 bytes) | 0 | 18446744073709551615 | unsigned long long | ||||
Signed 8-bit (1 bytes) | -128 | 127 | signed char | ||||
Signed 16-bit (2 bytes) | -32768 | 32767 | short | int | ||||
Signed 32-bit (4 bytes) | -2147483648 | 2147483647 | long | ||||
Signed 64-bit (8 bytes) | -9223372036854775808 | 9223372036854775807 | long long |
Units
Common Name | IEC Name | Bytes | |
---|---|---|---|
kilobyte (kB) | kibibyte (KiB) | 1024 | |
megabyte (MB) | mebibyte (MiB) | 1048576 | |
gigabyte (GB) | gibibyte (GiB) | 1073741824 | |
terabyte (TB) | tebibyte (TiB) | 1099511627776 | |
petabyte (PB) | pebibyte (PiB) | 1125899906842624 | |
See Wikipedia for larger units. |
1 | |
2 | |
4 | |
8 | |
16 | |
32 | |
64 | |
128 | |
256 | |
512 | |
1024 | |
2048 | |
4096 | |
8192 | |
16384 | |
32768 | |
65536 |