# C# Math - MinMagnitude() Method

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

### Syntax

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

### Parameters

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

### Return Value

Returns the number with smaller magnitude.

### Example:

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

```using System;

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

The output of the above code will be:

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

❮ C# Math Methods

5