3.1 Integers
Go’s numeric data types include several sizes of integers, floating-point numbers, and complex numbers. Each numeric type determines the size and signedness of its values. Let’s begin with integers.
Go provides both signed and unsigned integer arithmetic.
There are four distinct sizes of
signed integers—8, 16, 32, and 64 bits—represented by the types
int8
, int16
, int32
, and int64
, and corresponding unsigned
versions uint8
, uint16
, uint32
, and uint64
.
There are also two types called just int
and uint
that are the
natural or most efficient size for signed and unsigned integers on a particular platform;
int
is by far the most widely used numeric type. Both these types have the same size, either 32 or 64 bits, but one must not ...
Get The Go Programming Language now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.