Three-way comparison
Computing operation which compares two values / From Wikipedia, the free encyclopedia
Dear Wikiwand AI, let's keep it short by simply answering these key questions:
Can you list the top facts and stats about Three-way comparison?
Summarize this article for a 10 year old
SHOW ALL QUESTIONS
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++).