Three-way comparison

In computer science, a three-way comparison takes two values A and B belonging to a type with a total order and determines whether A < B, A = B, or A > B in a single operation, in accordance with the mathematical law of trichotomy.

It can be implemented in terms of a function (such as strcmp in C), a method (such as compareTo in Java), or an operator (such as the spaceship operator <=> in Perl, PHP and C++).


© MMXXIII Rich X Search. We shall prevail. All rights reserved. Rich X Search