I Spy Code - GO

Numeric types

Integers:

Integers are numbers without a decimal component. (..., -3, -2, -1, 0, 1, ...) Unlike the base10 decimal system we use to represent numbers, computers use a base-2 binary system.

Floating Point Numbers:

Floating point numbers are numbers that contain a decimal component (real numbers). (1.234, 123.4, 0.00001234, 12340000) Their actual representation on a computer is fairly complicated and not really necessary in order to know how to use them.

Source: (example.go)

package main
 
import "fmt"
 
func main() {
 
   // integer
   var i1 int = 100
   fmt.Println(i1)
 
   // integer shorthand
   i2 :=  200
   fmt.Println(i2)
 
   // float
   var f1 float32 = 1.2345
   fmt.Println(f1)
 
   // float shorthand
   f2 := 5.6789
   fmt.Println(f2)
}
 

Output:

$ go run example.go
100
200
1.2345
5.6789