Home

i32

i32 is a 32-bit signed integer type used in several programming languages and libraries. It represents whole numbers within the range -2,147,483,648 to 2,147,483,647 and requires four bytes of memory. On most platforms, signed 32-bit integers use two's complement representation, which provides a consistent way to perform arithmetic and bitwise operations.

In Rust, i32 is a primitive type and the canonical example of a 32-bit signed integer. The

i32 is commonly used wherever a fixed-width, small-range signed integer is appropriate. It is frequently employed

Overflow and behavior on exceeding the range are language-specific. For example, Rust performs checked overflow in

See also: i8, i16, i64, u32, int32_t, and related fixed-width integer types.

type
name
indicates
its
size,
and
literals
can
be
annotated
with
a
suffix
such
as
42i32.
Similar
fixed-width
signed
integer
types
exist
in
other
languages,
including
i8,
i16,
i64
in
Rust;
and
their
equivalents
in
C/C++
(int32_t)
and
many
other
ecosystems
(such
as
Java’s
int
or
Swift’s
Int32).
for
counters,
array
indexing,
and
numeric
computations
where
predictable
overflow
behavior
or
memory
usage
is
important.
The
four-byte
size
makes
it
a
good
match
for
performance-critical
code
that
needs
a
stable,
platform-independent
integer
width.
debug
builds
and
wrapping
on
release
builds;
C
and
C++
treat
signed
overflow
as
undefined
behavior;
Java
wraps
around
using
two's
complement
semantics.
Because
of
these
differences,
developers
must
consider
language-specific
rules
when
performing
arithmetic
near
the
limits
of
i32.