Numeric Data Types
Explore Go's numeric data types such as integers, floating-point numbers, and complex numbers. Understand how Go handles different sizes and signed or unsigned integers. Learn how to perform type conversions and arithmetic to produce correct results. Practice with examples focused on these number types.
Go supports integer, floating-point, and complex number values in various versions depending on the memory space they consume—this saves memory and computing time. Integer data types can be either signed or unsigned, which is not the case for floating-point numbers.
List of numeric data types
The table that follows lists the numeric data types of Go.
Data Type | Description |
| 8-bit signed integer |
| 16-bit signed integer |
| 32-bit signed integer |
| 64-bit signed integer |
| 32- or 64-bit signed integer |
| 8-bit unsigned integer |
| 16-bit unsigned integer |
| 32-bit unsigned integer |
| 64-bit unsigned integer |
| 32- or 64-bit unsigned integer |
| 32-bit floating-point number |
| 64-bit floating-point number |
| Complex number with |
| Complex number with |
The int and uint data types are special as they are the most efficient sizes for signed and unsigned integers on a given platform and can be either 32 or 64 bits each—their size is defined by Go itself. The int data type is the most widely used data type in Go due ...