simshadows

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)02552812^{8} - 1>2×102> 2 \times {10}^{2}unsigned char
Unsigned 16-bit (2 bytes)06553521612^{16} - 1>6×104> 6 \times {10}^{4}unsigned short | unsigned int
Unsigned 32-bit (4 bytes)0429496729523212^{32} - 1>4×109> 4 \times {10}^{9}unsigned long
Unsigned 64-bit (8 bytes)01844674407370955161526412^{64} - 1>1×1019> 1 \times {10}^{19}unsigned long long
Signed 8-bit (1 bytes)-12827-2^{7}<1×102< -1 \times {10}^{2}1272712^{7} - 1>1×102> 1 \times {10}^{2}signed char
Signed 16-bit (2 bytes)-32768215-2^{15}<3×104< -3 \times {10}^{4}3276721512^{15} - 1>3×104> 3 \times {10}^{4}short | int
Signed 32-bit (4 bytes)-2147483648231-2^{31}<2×109< -2 \times {10}^{9}214748364723112^{31} - 1>2×109> 2 \times {10}^{9}long
Signed 64-bit (8 bytes)-9223372036854775808263-2^{63}<9×1018< -9 \times {10}^{18}922337203685477580726312^{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