Function equal

  • Checks if two numbers are approximately equal within a specified tolerance.

    Parameters

    • x: number

      The first number to compare.

    • y: number

      The second number to compare.

    • Optional tolerance: number

      The maximum difference allowed between the numbers. Defaults to Constants.DELTA (for regular numbers) or 0n (for bigints).

    Returns boolean

    'true' if the numbers are approximately equal, 'false' otherwise.

    Example

    equal(3.14159, 3.14, 0.01);    // Returns true
    equal(10, 15, 0.1); // Returns false
  • Checks if two bigints are approximately equal within a specified tolerance.

    Parameters

    • x: bigint

      The first bigint to compare.

    • y: bigint

      The second bigint to compare.

    • Optional tolerance: bigint

      The maximum difference allowed between the numbers. Defaults to 0n .

    Returns boolean

    'true' if the bigint are approximately equal, 'false' otherwise.

    Example

    equal(2233n, 2233n, 0n);        // Returns true
    equal(10n, 15n, 1n); // Returns false

Generated using TypeDoc