# Implement the `<=>` three-way comparison operator on numbers Tags: [tag:code-golf][tag:number][tag:comparison] In C++, there exists a [`a <=> b` three-way](https://stackoverflow.com/questions/47466358/what-is-the-spaceship-three-way-comparison-operator-in-c) [comparison operator](https://en.cppreference.com/w/cpp/language/operator_comparison) that, for numerical types, does the following: - If `a < b`, then return `-1`. - If `a = b`, then return `0`. - If `a > b`, then return `1`. ## The Challenge Implement the **shortest** full program, function, method, or custom operator such that, when given two numbers of the same type `a` and `b`, - If `a < b`, then return `-1`. - If `a = b`, then return `0`. - If `a > b`, then return `1`. ### Bonuses If your language supports at least 2 number types (int, float, byte, long, etc.), and your solution is generic across multiple numerical types, you can **subtract 1%** from your score for each numeric type your solution supports. ### Notes - If you're writing in x86 assembly, [this question](https://codegolf.stackexchange.com/questions/259087/) may be of use to you. - This is [tag:code-golf], so shortest answer wins!