isCloseUlp
isCloseUlp(
a,b,maxUlps?):boolean
Defined in: packages/core/src/number/is-close-ulp.ts:23
Tests whether two numbers are within maxUlps representable steps of each
other.
A test about float representation, not about a domain quantity: use it for
round-trip checks, codec conformance and kernel validation. It cannot express
“close to zero” — every normal number is astronomically many ULPs from 0,
so only ±0 and the first few subnormals ever pass. Reach for
isCloseTo whenever the tolerance means something in the caller’s
units.
Slower than the other forms, since the ULP distance needs BigInt.
Parameters
Section titled “Parameters”number
The first number to compare.
number
The second number to compare.
maxUlps?
Section titled “maxUlps?”number = 4
The maximum number of ULPs that the two numbers can differ by to be considered close. Defaults to 4.
Returns
Section titled “Returns”boolean
true if the numbers are close within the specified ULPs, false
otherwise. NaN is never close to anything, including itself.