This is a creation in Article, where the information may have evolved or changed.
An integer type has unsigned and signed two types. Go supports both int and uint , the lengths of the two types are the same, but the exact length depends on the implementation of the different compilers. ~ ~ The current GCC and GCCGO compilers use 32-bit representation on both 32-bit and 64-bit int platforms uint , but may increase to 64 bits in the future on 64-bit platforms. Go also has a direct definition of the type of the number of digits:,,, rune int8 int16 int32 , int64 and byte , uint8 uint16 uint32 uint64 ,,,. Which rune is int32 the nickname, byte is uint8 the nickname.
It is important to note that these types of variables are not allowed to assign values or operations to each other, or will cause the compiler to error when compiling.
The code below will produce an error
var a int8
var b int32
C:=a + b
In addition, int is not interoperable with int32, although the length of int is three bit.
There are two types of floating-point numbers float32 float64 (no float type), and the default is float64 .
Is that all? No! Go also supports complex numbers. Its default type is complex128 (64-bit real number + 64-bit imaginary number). If smaller is required, there are also complex64 (32-bit real numbers + 32-bit imaginary number). In the form of a complex RE + IMi number, which RE is the real part, IM is the imaginary part, and the last i is the imaginary unit. Here is an example of using a complex number:
var c complex64 = 5+5i//output: (5+5i)fmt.Printf("Value is: %v", c)