:
static complex root(complex a, complex b, complex c) {
return (-b + complex.sqrt(b*b-4*a*c))/(2*a);
}
Instead Java currently requires:
static Complex root(Complex a, Complex b, Complex c) {
Complex b2 = Complex.multiply(b,b);
Complex ac4 = Complex.multiply(4,Complex.multiply(a,c));
Complex discrim = Complex.sqrt(Complex.subtract(b2,ac4));
return Complex.divide(Complex.subtract(discrim,b)),Complex.multiply(2,a)));
}
A complex number type would have to be accompanied by the standard unary and binary operators. The operators should allow for mixed operands such as float and complex. Operators without a complex extension, such as increment and modulus, would, of course, not exist. Furthermore, the class should be accompanied by a set of static class methods corresponding to the java.lang.Math package for the double type.