All files / complex-js/methods mod.ts

0% Statements 0/8
0% Branches 0/1
0% Functions 0/1
0% Lines 0/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14                           
import trunc from '../functions/trunc';
import { IComplex, IComplexConstructor } from '../internal/complex';
import div from './div';
import mul from './mul';
import sub from './sub';
 
export default function mod<T extends IComplex> (Complex: IComplexConstructor<T>, lhs: IComplex, r: IComplex | number, i = 0): T {
  // lhs % rhs = lhs - (trunc(lhs / rhs) * rhs)
  const q = div(Complex, lhs, r, i);
  const p = mul(Complex, trunc(Complex, q), r, i);
 
  return sub(Complex, lhs, p);
}