three way comparison

Solutions on MaxInterview for three way comparison by the best coders in the world

showing results for - "three way comparison"
Edoardo
27 Nov 2020
1#include <compare>
2#include <iostream>
3 
4int main() {
5    double foo = -0.0;
6    double bar = 0.0;
7 
8    auto res = foo <=> bar;
9 
10    if (res < 0)
11        std::cout << "-0 is less than 0";
12    else if (res == 0)
13        std::cout << "-0 and 0 are equal";
14    else if (res > 0)
15        std::cout << "-0 is greater than 0";
16}
queries leading to this page
three way comparisonthree way comparison