While you could use a switch expression for this (see @Klamsi's answer), there's a better way:
return Math.Round(self, decimals).CompareTo(Math.Round(value, decimals));
From the docs:
Returns
Int32
A signed number indicating the relative values of this instance and value.
Return Value |
Description |
Less than zero |
This instance is less than value, or this instance is not a number (NaN) and value is a number. |
Zero |
This instance is equal to value, or both this instance and value are not a number (NaN), PositiveInfinity, or NegativeInfinity. |
Greater than zero |
This instance is greater than value, or this instance is a number and value is not a number (NaN). |
(Although the docs say the return value can be anything, in practice all BCL types return -1, 0 or 1).