float types are used to represent numbers with decimal value.
Go provides two sizes of floating-point numbers, float32
and float64
.
main.govar myFloat float64myFloat = 3.14
Floats are declared using one of the following ways:
main.govar f float32 = 20.6var h float64 = 40.2var h = 40.2h := 40.2
If we are not specifying type like in 3rd and 4th declaration, it will default to float64
Zero value for float is 0.0