See Original text in context
multi sub infix:<=~=>(Any, Any)multi sub infix:<=~=>(Int, Int)multi sub infix:<=~=>(Num, Num)multi sub infix:<=~=>(Rational, Rational)multi sub infix:<=~=>(Real, Real)multi sub infix:<=~=>(Complex, Complex)multi sub infix:<=~=>(Numeric, Numeric)
The approximately-equal operator ≅
, whose ASCII variant is =~=
, calculates the relative difference between the left-hand and right-hand sides and returns True
if the difference is less than $*TOLERANCE
(which defaults to 1e-15). However, if either side is zero then it checks that the absolute difference between the sides is less than $*TOLERANCE
. Note that this operator is not arithmetically symmetrical (doesn't do ± Δ):
my = 1;say ( + ) ; # OUTPUT: «False»say ( - ) ; # OUTPUT: «True»
You can change $*TOLERANCE
lexically:
Note that setting $*TOLERANCE = 0 will cause all comparisons to fail.