@technobuddha/library
Version:
A large library of useful functions
20 lines (19 loc) • 729 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.almostEquals = void 0;
/**
* Tests whether the two values are equal to each other, within a certain
* tolerance, taking into account floating point errors (numbers within EPSILON).
*
* @param a First number to compare.
* @param b Second number to compare.
* @param __namedParameters see {@link Options}
* @default tolerance 0
* @return true if *a* and *b* are nearly equal.
*/
function almostEquals(a, b, _a) {
var _b = _a === void 0 ? {} : _a, _c = _b.tolerance, tolerance = _c === void 0 ? 0 : _c;
return Math.abs(a - b) <= (tolerance + Number.EPSILON);
}
exports.almostEquals = almostEquals;
exports.default = almostEquals;