# C# Math - MaxMagnitude() Method

The C# MaxMagnitude() method returns the number with larger magnitude between the two arguments. If either of the arguments is NaN, the method returns NaN.

### Syntax

```public static double MaxMagnitude (double arg1, double arg2);
```

### Parameters

 `arg1` Specify value to compare. `arg2` Specify value to compare.

### Return Value

Returns the number with larger magnitude.

### Example:

In the example below, MaxMagnitude() method is used to find out the number with larger magnitude between the two arguments.

```using System;

class MyProgram {
static void Main(string[] args) {
Console.WriteLine("Math.MaxMagnitude(50, -100) = "
+ Math.MaxMagnitude(50, -100));
Console.WriteLine("Math.MaxMagnitude(-5.5, 10.5) = "
+ Math.MaxMagnitude(-5.5, 10.5));
Console.WriteLine("Math.MaxMagnitude(5, -10.5) = "
+ Math.MaxMagnitude(5, -10.5));
Console.WriteLine("Math.MaxMagnitude(10, Double.NaN) = "
+ Math.MaxMagnitude(10, Double.NaN));
Console.WriteLine("Math.MaxMagnitude(10, Double.NegativeInfinity) = "
+ Math.MaxMagnitude(10, Double.NegativeInfinity));
Console.WriteLine("Math.MaxMagnitude(10, Double.PositiveInfinity) = "
+ Math.MaxMagnitude(10, Double.PositiveInfinity));
}
}
```

The output of the above code will be:

```Math.MaxMagnitude(50, -100) = -100
Math.MaxMagnitude(-5.5, 10.5) = 10.5
Math.MaxMagnitude(5, -10.5) = -10.5
Math.MaxMagnitude(10, Double.NaN) = NaN
Math.MaxMagnitude(10, Double.NegativeInfinity) = -Infinity
Math.MaxMagnitude(10, Double.PositiveInfinity) = Infinity
```

❮ C# Math Methods

5