Documentation for infix
=~= assembled from the following types:
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␤»
The tolerance is supposed to be modifiable via an adverb:
my (, ) = 42, 42.1;say :tolerance(.1);
However, this is not yet implemented. The same effect can be achieved by assigning to $*TOLERANCE.
Note that setting $*TOLERANCE = 0 will cause all comparisons to fail.