Skip to content

Commit 8351794

Browse files
xljxlj
authored andcommitted
fix compile error
1 parent a1a30ec commit 8351794

4 files changed

Lines changed: 27 additions & 26 deletions

File tree

109-Complex-Numbers/complex-0.gop

Lines changed: 0 additions & 9 deletions
This file was deleted.

109-Complex-Numbers/complex-1.gop

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Parts of a Complex Number
2-
// There are two parts of a complex number. The real and imaginary part. We use functions to get those.
1+
# Initializing Complex Numbers
2+
// There are two complex types in Go+. The complex64 and the complex128.
3+
// Initializing complex numbers is really easy. You can use the constructor or the initialization syntax as well.
34

4-
c := complex(23, 31)
5-
realPart := real(c) // gets real part
6-
imagPart := imag(c) // gets imaginary part
7-
println realPart, imagPart
5+
c1 := complex(10, 11) // constructor init
6+
c2 := 10 + 11i // complex number init syntax
7+
println c1, c2

109-Complex-Numbers/complex-2.gop

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
# Operations on a Complex Number
2-
// A complex variable can do any operation like addition, subtraction, multiplication, and division.
3-
//
4-
// Let’s see an example to perform mathematical operations on the complex numbers.
1+
# Parts of a Complex Number
2+
// There are two parts of a complex number. The real and imaginary part. We use functions to get those.
53

6-
c1 := complex(2, 3)
7-
c2 := 4 + 5i // complex initializer syntax a + ib
8-
c3 := c1 + c2 // addition just like other variables
9-
println "Add: ", c3 // prints "Add: (6+8i)"
10-
re := real(c3) // get real part
11-
im := imag(c3) // get imaginary part
12-
println re, im // prints 6 8
4+
cc := complex(23, 31)
5+
realPart := real(cc) // gets real part
6+
imagPart := imag(cc) // gets imaginary part
7+
println realPart, imagPart

109-Complex-Numbers/complex-3.gop

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Operations on a Complex Number
2+
// A complex variable can do any operation like addition, subtraction, multiplication, and division.
3+
//
4+
// Let’s see an example to perform mathematical operations on the complex numbers.
5+
6+
c11 := complex(10, 11) // constructor init
7+
c22 := 10 + 11i // complex number init syntax
8+
9+
ccc := complex(2, 3)
10+
cc2 := 4 + 5i // complex initializer syntax a + ib
11+
cc3 := c11 + c22 // addition just like other variables
12+
println "Add: ", cc3 // prints "Add: (6+8i)"
13+
re := real(cc3) // get real part
14+
im := imag(cc3) // get imaginary part
15+
println ccc, re, im // prints 6 8

0 commit comments

Comments
 (0)