C# Math Max(Double, Double)
Description
Math Max(Double, Double)
returns the larger of two double-precision
floating-point numbers.
Syntax
Math.Max(Double, Double)
has the following syntax.
public static double Max(
double val1,
double val2
)
Parameters
Math.Max(Double, Double)
has the following parameters.
val1
- The first of two double-precision floating-point numbers to compare.val2
- The second of two double-precision floating-point numbers to compare.
Returns
Math.Max(Double, Double)
method returns Parameter val1 or val2, whichever is larger. If val1, val2, or both val1 and
val2 are equal to NaN, NaN is returned.
Example
The following example demonstrates how to use the Max method to return and display the greater of two variables.
// This example demonstrates Math.Max()
using System;
/*from w ww .j a v a 2 s. c o m*/
class Sample
{
public static void Main()
{
double xDouble1 = 6.0, xDouble2 = 56.0;
Console.WriteLine(Math.Max(xDouble1, xDouble2));
}
}
The code above generates the following result.