August 2019
Beginner to intermediate
798 pages
17h 2m
English
Similar to floating-point numbers, Go offers two complex number types named complex64 and complex128. The first one uses two float32: one for the real part and the other for the imaginary part of the complex number, whereas complex128 uses two float64. Complex numbers are expressed in the form of a + bi, where a and b are real numbers, and i is a solution of the equation x2 = −1.
All these numeric data types are illustrated in the code of numbers.go, which will be presented in three parts.
The first part of numbers.go is as follows:
package main import ( "fmt" ) func main() { c1 := 12 + 1i c2 := complex(5, 7) fmt.Printf("Type of c1: %T\n", c1) fmt.Printf("Type of c2: %T\n", c2) var c3 complex64 = complex64(c1 + c2) fmt.Println("c3:", ...Read now
Unlock full access