Integer ranges and powers of two

The exact limits of every fixed-width integer type from 8 to 64 bits, the values of 2⁶³ and 2⁶⁴ that define the 64-bit boundaries, and a full table of powers of two from 2⁰ to 2⁶⁴ in decimal and hexadecimal. Every number on this page is computed at build time with arbitrary-precision arithmetic.

Signed and unsigned ranges by bit width

With n bits there are exactly 2ⁿ distinct patterns; an unsigned type uses all of them for 0 to 2ⁿ−1. A signed type stores negatives in two's complement, spending half the patterns on −2ⁿ⁻¹ … −1, which leaves 0 … 2ⁿ⁻¹−1 for the non-negative side — so the signed maximum is 2ⁿ⁻¹−1 and the minimum is −2ⁿ⁻¹.

Exact minimum and maximum of each fixed-width integer type
TypeBitsMin (decimal)Max (decimal)Max (hex)Also called
int8 8 −128 127 0x7F C int8_t / signed char, Rust i8, Swift Int8
uint8 8 0 255 0xFF C uint8_t, Rust u8, Swift UInt8, Go byte
int16 16 −32 768 32 767 0x7FFF C short, Java short, Rust i16, Swift Int16
uint16 16 0 65 535 0xFFFF C unsigned short, Rust u16, Swift UInt16
int32 32 −2 147 483 648 2 147 483 647 0x7FFFFFFF C int, Java int, Rust i32, Swift Int32
uint32 32 0 4 294 967 295 0xFFFFFFFF C unsigned int, Rust u32, Swift UInt32
int64 64 −9 223 372 036 854 775 808 9 223 372 036 854 775 807 0x7FFFFFFFFFFFFFFF C long long, Java long, Rust i64, Swift Int (64-bit platforms)
uint64 64 0 18 446 744 073 709 551 615 0xFFFFFFFFFFFFFFFF C unsigned long long, Rust u64, Swift UInt (64-bit platforms)

2⁶³ and 2⁶⁴: the 64-bit limits

These five values come up constantly in overflow checks, database column types and "why is my counter negative" bugs:

  • 2⁶³ = 9 223 372 036 854 775 808 = 0x8000000000000000 — one past the largest signed 64-bit value.
  • 2⁶³ − 1 = 9 223 372 036 854 775 807 = 0x7FFFFFFFFFFFFFFF — int64 max.
  • −2⁶³ = −9 223 372 036 854 775 808 — int64 min; its 64-bit two's complement pattern is 0x8000000000000000.
  • 2⁶⁴ = 18 446 744 073 709 551 616 = 0x10000000000000000 — needs 65 bits, so it does not fit in any 64-bit type.
  • 2⁶⁴ − 1 = 18 446 744 073 709 551 615 = 0xFFFFFFFFFFFFFFFF — uint64 max; the same pattern reads as −1 in int64.

Powers of two from 2⁰ to 2⁶⁴

Each row is linkable by exponent, for example /reference/integer-ranges/#2-63.

Powers of two from 2⁰ to 2⁶⁴, in decimal and hexadecimal
PowerDecimalHexNote
2⁰ 1 0x1
2¹ 2 0x2
2² 4 0x4
2³ 8 0x8
2⁴ 16 0x10
2⁵ 32 0x20
2⁶ 64 0x40
2⁷ 128 0x80 int8 max + 1
2⁸ 256 0x100 One byte holds 256 values (0–255)
2⁹ 512 0x200
2¹⁰ 1 024 0x400 1 KiB
2¹¹ 2 048 0x800
2¹² 4 096 0x1000
2¹³ 8 192 0x2000
2¹⁴ 16 384 0x4000
2¹⁵ 32 768 0x8000 int16 max + 1
2¹⁶ 65 536 0x10000 64 KiB; uint16 max + 1
2¹⁷ 131 072 0x20000
2¹⁸ 262 144 0x40000
2¹⁹ 524 288 0x80000
2²⁰ 1 048 576 0x100000 1 MiB
2²¹ 2 097 152 0x200000
2²² 4 194 304 0x400000
2²³ 8 388 608 0x800000
2²⁴ 16 777 216 0x1000000
2²⁵ 33 554 432 0x2000000
2²⁶ 67 108 864 0x4000000
2²⁷ 134 217 728 0x8000000
2²⁸ 268 435 456 0x10000000
2²⁹ 536 870 912 0x20000000
2³⁰ 1 073 741 824 0x40000000 1 GiB
2³¹ 2 147 483 648 0x80000000 int32 max + 1
2³² 4 294 967 296 0x100000000 uint32 max + 1
2³³ 8 589 934 592 0x200000000
2³⁴ 17 179 869 184 0x400000000
2³⁵ 34 359 738 368 0x800000000
2³⁶ 68 719 476 736 0x1000000000
2³⁷ 137 438 953 472 0x2000000000
2³⁸ 274 877 906 944 0x4000000000
2³⁹ 549 755 813 888 0x8000000000
2⁴⁰ 1 099 511 627 776 0x10000000000 1 TiB
2⁴¹ 2 199 023 255 552 0x20000000000
2⁴² 4 398 046 511 104 0x40000000000
2⁴³ 8 796 093 022 208 0x80000000000
2⁴⁴ 17 592 186 044 416 0x100000000000
2⁴⁵ 35 184 372 088 832 0x200000000000
2⁴⁶ 70 368 744 177 664 0x400000000000
2⁴⁷ 140 737 488 355 328 0x800000000000
2⁴⁸ 281 474 976 710 656 0x1000000000000
2⁴⁹ 562 949 953 421 312 0x2000000000000
2⁵⁰ 1 125 899 906 842 624 0x4000000000000
2⁵¹ 2 251 799 813 685 248 0x8000000000000
2⁵² 4 503 599 627 370 496 0x10000000000000
2⁵³ 9 007 199 254 740 992 0x20000000000000
2⁵⁴ 18 014 398 509 481 984 0x40000000000000
2⁵⁵ 36 028 797 018 963 968 0x80000000000000
2⁵⁶ 72 057 594 037 927 936 0x100000000000000
2⁵⁷ 144 115 188 075 855 872 0x200000000000000
2⁵⁸ 288 230 376 151 711 744 0x400000000000000
2⁵⁹ 576 460 752 303 423 488 0x800000000000000
2⁶⁰ 1 152 921 504 606 846 976 0x1000000000000000
2⁶¹ 2 305 843 009 213 693 952 0x2000000000000000
2⁶² 4 611 686 018 427 387 904 0x4000000000000000
2⁶³ 9 223 372 036 854 775 808 0x8000000000000000 int64 max + 1
2⁶⁴ 18 446 744 073 709 551 616 0x10000000000000000 uint64 max + 1

Overflow: what happens past the limit

Fixed-width arithmetic is modular: in unsigned 8-bit, 255 + 1 wraps to 0, and in signed 8-bit, 127 + 1 wraps to −128, because the carry out of the top bit is simply discarded. What your language does about it varies — C leaves signed overflow undefined, Java wraps silently, Swift traps at runtime, and Rust panics in debug builds but wraps in release. The two's complement calculator lets you see the wrapped bit pattern for any width, and the two's complement guide explains why the range is asymmetric in the first place.

Related tools and guides