Skip to content

Commit 30d87e2

Browse files
committed
[operators] numeric comparison operators
1 parent 65fff9b commit 30d87e2

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

lib/operators.pod

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,4 +576,68 @@ Constructs a L<Range> from the arguments, excluding the start point.
576576
577577
Constructs a L<Range> from the arguments, excluding both start and end point.
578578
579+
=head1 Chaining Binary Precedence
580+
581+
=head2 infix ==
582+
583+
proto sub infix:<==>($, $) returns Bool:D is assoc:<chain>
584+
multi sub infix:<==>(Any, Any)
585+
multi sub infix:<==>(Int:D, Int:D)
586+
multi sub infix:<==>(Num:D, Num:D)
587+
multi sub infix:<==>(Rational:D, Rational:D)
588+
multi sub infix:<==>(Real:D, Real:D)
589+
multi sub infix:<==>(Complex:D, Complex:D)
590+
multi sub infix:<==>(Numeric:D, Numeric:D)
591+
592+
Coerces both arguments to L<Numeric> if necessary, and returns C<True>
593+
if they are equal.
594+
595+
=head2 infix !=
596+
597+
proto sub infix:<!=>(Mu, Mu) returns Bool:D is assoc<chain>
598+
599+
Coerces both arguments to L<Numeric>, and returns C<True> if they are
600+
distinct.
601+
602+
=head2 infix <
603+
604+
proto sub infix:«<»(Any, Any) returns Boold:D is assoc<chain>
605+
multi sub infix:«<»(Int:D, Int:D)
606+
multi sub infix:«<»(Num:D, Num:D)
607+
multi sub infix:«<»(Real:D, Real:D)
608+
609+
Coerces both arguments to L<Real>, and returns C<True> if the first argument
610+
is smaller than the second.
611+
612+
=head2 infix <=
613+
614+
proto sub infix:«<=»(Any, Any) returns Boold:D is assoc<chain>
615+
multi sub infix:«<=»(Int:D, Int:D)
616+
multi sub infix:«<=»(Num:D, Num:D)
617+
multi sub infix:«<=»(Real:D, Real:D)
618+
619+
Coerces both arguments to L<Real>, and returns C<True> if the first argument
620+
is smaller than or equal to the second.
621+
622+
623+
=head2 infix >
624+
625+
proto sub infix:«>»(Any, Any) returns Boold:D is assoc<chain>
626+
multi sub infix:«>»(Int:D, Int:D)
627+
multi sub infix:«>»(Num:D, Num:D)
628+
multi sub infix:«>»(Real:D, Real:D)
629+
630+
Coerces both arguments to L<Real>, and returns C<True> if the first argument
631+
is larger than the second.
632+
633+
=head2 infix >=
634+
635+
proto sub infix:«>=»(Any, Any) returns Boold:D is assoc<chain>
636+
multi sub infix:«>=»(Int:D, Int:D)
637+
multi sub infix:«>=»(Num:D, Num:D)
638+
multi sub infix:«>=»(Real:D, Real:D)
639+
640+
Coerces both arguments to L<Real>, and returns C<True> if the first argument
641+
is larger than or equal to the second.
642+
579643
=end pod

0 commit comments

Comments
 (0)