Last active
July 3, 2022 15:28
-
-
Save HORKimhab/728ccb92864963bb88c2919dff314119 to your computer and use it in GitHub Desktop.
golang-complex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
// func complex(real, imaginary FloatType) ComplexType | |
// Initializing Complex Numbers | |
complex1 := complex(12, 22) // Constructor init | |
complex2 := 12 + 223i // complex number init syntax | |
// var a complex128 = complex(6, 2) | |
var b complex64 = complex(9, 2) | |
realPart := real(complex1) | |
imag2 := imag(complex2) | |
fmt.Println("Complex Number") | |
fmt.Println(complex1) | |
fmt.Println(complex2) | |
fmt.Println(realPart) | |
fmt.Println(imag2) | |
fmt.Printf("%T\n", b) | |
fmt.Println(real(b)) | |
} | |
// https://www.tutorialandexample.com/complex-number-data-types-in-golang | |
// https://www.geeksforgeeks.org/data-types-in-go/ | |
// https://golangdocs.com/complex-numbers-in-golang | |
// https://www.educative.io/answers/what-is-type-complextype-in-golang |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment