-
Notifications
You must be signed in to change notification settings - Fork 0
/
ComplexDouble.java
60 lines (48 loc) · 1.23 KB
/
ComplexDouble.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Class ComplexDouble for
// program HelloWorld by Ray Arias
// version 1.00.01-delta(rc)-Thales of Miletis
// 03 September 2022
// subpackage: QuadraticFormula, version 1.00.01-delta(rc)-Thales of Miletis
// semantic version 1.0.1-rc
public class ComplexDouble {
double re;
double im;
public ComplexDouble() {
this.re = 0.0;
this.im = 0.0;
}
public ComplexDouble(double re) {
this.re = re;
this.im = 0.0;
}
public ComplexDouble(double re, double im) {
this.re = re;
this.im = im;
}
public void re(double re) {
this.re = re;
}
public void im(double im) {
this.im = im;
}
public void set(double re, double im) {
this.re = re;
this.im = im;
}
public double re() {
return this.re;
}
public double im() {
return this.im;
}
public ComplexDouble get() {
return this;
}
public String toString() {
String result = "";
if (im > 0) result = "" + re + " + " + im + "i";
else if (im < 0) result = "" + re + " – " + (-im) + "i";
else /* (im == 0) */ result = "" + re;
return result;
}
}