[Java] 复数的乘法运算 →→→→→进入此内容的聊天室

来自 , 2021-03-22, 写在 Java, 查看 136 次.
URL http://www.code666.cn/view/a7aeed74
  1.         /**
  2.          * 复数的乘法运算。
  3.          * c = a * b的运算法则是:
  4.          * c.实部 = a.实部 * b.实部 - a.虚部 * b.虚部;
  5.          * c.虚部 = a.虚部 * b.实部 + a.实部 * b.虚部;
  6.          * @param aComNum  乘数
  7.          * @return
  8.          */
  9.         public ComplexNumber multiply(ComplexNumber aComNum) {
  10.                 if (aComNum == null) {
  11.                         System.err.println("对象不能够为null!");
  12.                         return new ComplexNumber();
  13.                 }
  14.                 double newReal = this.realPart * aComNum.realPart - this.imaginaryPart
  15.                                 * aComNum.imaginaryPart;
  16.                 double newImaginary = this.realPart * aComNum.imaginaryPart
  17.                                 + this.imaginaryPart * aComNum.realPart;
  18.                 ComplexNumber result = new ComplexNumber(newReal, newImaginary);
  19.                 return result;
  20.         }

回复 " 复数的乘法运算"

这儿你可以回复上面这条便签

captcha