almostEqualRelativeI function

bool almostEqualRelativeI (double a, double b, int decimalPlaces)

Compares two doubles and determines if they are equal to within the specified number of decimal places or not. If the numbers are very close to zero an absolute difference is compared, otherwise the relative difference is compared.

Implementation

bool almostEqualRelativeI(double a, double b, int decimalPlaces) =>
    almostEqualNormRelativeI(a, b, a - b, decimalPlaces);