Numbers Comparison

You have two real numbers and you want to get the greater one. How would you do this? I am going to show you a few variants to solve this problem.

1. Direct comparison

This method just checks: if a is greater than b then returns a else – returns b.

2. Using arithmetic operators and boolean expressions

Actually, this is not working in C#, but in C++. In C++, a value of type bool can be converted to a value of type int; in other words, false is equivalent to zero and true is equivalent to nonzero values. In C#, there is no conversion between the bool type and other types.

3. Using Abs method

I leave this for you to check its truth.