C# Tutorial C# Advanced C# Resources
Python Java C++ C C# PHP R SQL DS Algo InterviewQ

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(10, -20));
   Console.WriteLine(Math.MinMagnitude(-10, -50));
  }
}

The output of the above code will be:

10
-10

❮ C# Math Methods

5