History of `isapprox` in languages

How? You’re asking if something is approximately zero — and to do it “intuitively,” in the way that you mean. But how do I know what you mean, even if you’re explicitly using units? A high energy physicist might care about distances down to 10^-35m, but an architect would be okay with a millimeter or two and a GPS app happy to be within a meter.

Float64 can meaningfully represent over 600 orders of magnitude — and every single one of those orders of magnitude has ~16 digits of precision. You can always ask if ~half the digits match — that’s the default rtol. But how could I ever guess how many of those orders of magnitude should be considered “insignificant” to you? That’s the atol.

You can always define your own comparator — unicode combining characters or sub-/super-scripts are great for this:

julia> ≈ₐ(x,y) = isapprox(x, y, atol=1e-10)
≈ₐ (generic function with 1 method)

julia> 1e-10 ≈ₐ 0.0
true
16 Likes