15. Complex Numbers
Complex Type
complex
types are used to work with complex numbers. Go has Go two types of complex numbers, complex64
and complex128
To create complex number, we use build in complex
function.
Declaring Complex Number
Complex numbers can be declared using any of the below way
main.go
When type is not specified, complex number defaults to complex128
Since complex numbers must be created using complex()
function, these do not have a corresponding zero value.
Go provides two sizes of complex numbers, complex64
and complex128
. These are used to represent complex numbers.
Declaring Complex Type
We need to use in-build complex
function to create complex type.
main.go
If no type is specified, it defaults to complex128
Last updated