Numbers In 'Go'(Learn 'Go' - Part 7)
In Go, there are several types to represent numbers.
For Integers, we have
- int8
- int16
- int32
- int64
- uint8
- uint16
- uint32
- uint64
'uint' means unsigned integers and 8,16,32,64 represent how many bits each one use. 'int' represents signed integers and they can only be used for positive integers like 1,2,3 and so on.
We can also use 'byte' for 'uint8' and 'rune' for 'int32'.
For Floating numbers, we have
- float32
- float64
Using a larger integer type or floating number type increases its precision.
Besides the regular ones listed above, we also have some other types to represent numbers that come in use occasionally.
- NaN ~ Not a Number
For complex numbers, we have
- complex64
- complex128
While dealing with numbers, we will need to use operators.
- '+' for addition
- '-' for subtraction
- '*' for multiplication
- '/' for division
- '%' for modulus or remainder
Previous Posts In The Series
Introduction To 'Go' Programming Language(Learn 'Go' - Part 1)
25 Basic Keywords Of The Go Programming Language (Learn 'Go' - Part 2)
How To Set The Go Programming Environment On Your System?(Learn 'Go' - Part 3)
Create Your First Program In Go Language (Learn 'Go' - Part 4)
Strings In 'Go'(Learn 'Go' - Part 5)
Booleans In 'Go'(Learn 'Go' - Part 6)
Upcoming Posts
Variables In 'Go'(Learn 'Go' - Part 8)