Questions tagged [comparison]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
-2 votes
1 answer
200 views

Comparator function in Javascript [closed]

Need to write a JS function compare(a,b) for numbers which return 1 when a > b, 0 when a == b, -1 when a < b. Also following properties should hold: compare(NaN, NaN) = 0 NaN is bigger than any ...
Ihromant's user avatar
19 votes
56 answers
5k views

Implement the `<=>` three-way comparison operator on numbers

In C++, there exists a a <=> b three-way comparison operator that, for numerical types, does the following: If a < b, ...
bigyihsuan's user avatar
  • 8,528