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.

DescriptionMinimumMaximumMinimum C Type
Unsigned 8-bit (1 bytes)025528−12^{8} - 1>2×102> 2 \times {10}^{2}unsigned char
Unsigned 16-bit (2 bytes)065535216−12^{16} - 1>6×104> 6 \times {10}^{4}unsigned short | unsigned int
Unsigned 32-bit (4 bytes)04294967295232−12^{32} - 1>4×109> 4 \times {10}^{9}unsigned long
Unsigned 64-bit (8 bytes)018446744073709551615264−12^{64} - 1>1×1019> 1 \times {10}^{19}unsigned long long
Signed 8-bit (1 bytes)-128−27-2^{7}<−1×102< -1 \times {10}^{2}12727−12^{7} - 1>1×102> 1 \times {10}^{2}signed char
Signed 16-bit (2 bytes)-32768−215-2^{15}<−3×104< -3 \times {10}^{4}32767215−12^{15} - 1>3×104> 3 \times {10}^{4}short | int
Signed 32-bit (4 bytes)-2147483648−231-2^{31}<−2×109< -2 \times {10}^{9}2147483647231−12^{31} - 1>2×109> 2 \times {10}^{9}long
Signed 64-bit (8 bytes)-9223372036854775808−263-2^{63}<−9×1018< -9 \times {10}^{18}9223372036854775807263−12^{63} - 1>9×1018> 9 \times {10}^{18}long long

Units

Common NameIEC NameBytes
kilobyte (kB)kibibyte (KiB)10241{1024}^11024
megabyte (MB)mebibyte (MiB)10242{1024}^21048576
gigabyte (GB)gibibyte (GiB)10243{1024}^31073741824
terabyte (TB)tebibyte (TiB)10244{1024}^41099511627776
petabyte (PB)pebibyte (PiB)10245{1024}^51125899906842624
See Wikipedia for larger units.
202^{0}1
212^{1}2
222^{2}4
232^{3}8
242^{4}16
252^{5}32
262^{6}64
272^{7}128
282^{8}256
292^{9}512
2102^{10}1024
2×10242 \times 10242048
4×10244 \times 10244096
8×10248 \times 10248192
16×102416 \times 102416384
32×102432 \times 102432768
64×102464 \times 102465536