UNPKG

@rayyamhk/complex

Version:

A lightweight and easy-to-use library for you to manipulate complex numbers

19 lines (16 loc) 529 B
"use strict"; /** * Calculates the difference of two Complex Number. * @memberof Complex * @static * @param {Complex} num1 - The Complex Number on the left of '-' operator. * @param {Complex} num2 - The Complex Number on the right of '-' operator. * @returns {Complex} The difference of two Complex Numbers */ function subtract(num1, num2) { if (!(num1 instanceof this) || !(num2 instanceof this)) { return this.NaN; } return new this(num1.re - num2.re, num1.im - num2.im); } module.exports = subtract;