204k views
5 votes
In the GO programming language you can't declare a float, it must be a float32 or float64. Why do you think this is done if the data type is not necessary? Why do you think they used float64 instead of double? Think about the lexical analyzer and how it interprets a symbol.

1 Answer

2 votes

Answer and Explanation:

a. Go programming language specifies data types and does not allow mixing them up. Therefore instead of just declaring a float variable, one has to be specific and declare either a float32(single precision floating point number) variable or float64(double precision floating point number). Float64 numbers occupy larger spaces and could be slower in some systems but they represent more accurate numbers.

b. Float64 is more accurate and is used by most math libraries. Float64 and double are same thing, although double precision numbers are called float64 in Go, it doesn't affect the lexical analyzer in any way.

User Yamilka
by
5.4k points