complexTruncate function
Truncate the real and imaginary part of an imaginary number. This function is very useful for compere two double numbers.
val
: a Complex valuefractionDigits
: number of decimal digits
Examples
print(complexTruncate(Complex.ri(1.4747474747474747, 1.4747474747474747), 3));
/* output:
Complex(real: 1.475, imaginary: 1.475);
*/
Implementation
Complex complexTruncate(Complex val, int fractionDigits) {
return Complex.ri(truncate(val.real, fractionDigits),
truncate(val.imaginary, fractionDigits));
}