Skip to content

Commit b9e46c6

Browse files
committed
complex numbers
1 parent 58b2038 commit b9e46c6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"math/cmplx"
6+
)
7+
8+
func main() {
9+
x := complex(2.5, 3.1)
10+
y := complex(10.2, 2)
11+
fmt.Println(x + y)
12+
fmt.Println(x - y)
13+
fmt.Println(x * y)
14+
fmt.Println(x / y)
15+
fmt.Println(real(x))
16+
fmt.Println(imag(x))
17+
fmt.Println(cmplx.Abs(x))
18+
}

0 commit comments

Comments
 (0)