complex types are used to work with complex numbers. Go has Go two types of complex numbers,
To create complex number, we use build in
Complex numbers can be declared using any of the below way
main.govar c1 complex128 = complex(2, 3)var c2 complex64 = complex(3, 4)var c1 = complex(2, 3)c1 := complex(2, 3)
When type is not specified, complex number defaults to
Since complex numbers must be created using
complex() function, these do not have a corresponding zero value.
Go provides two sizes of complex numbers,
complex128 . These are used to represent complex numbers.
We need to use in-build
complex function to create complex type.
main.govar x = complex(2, 2)var x complex128 = complex(2,2)var y complex64 = complex(3,4)
If no type is specified, it defaults to