Facebook Page Twitter Page LinkedIn Page
× C# Tutorial C# Advanced C# Resources


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

The output of the above code will be:

-20
-50

❮ C# Math Methods

5