C# Math Min(Double, Double)

Description

Math Min(Double, Double) returns the smaller of two double-precision floating-point numbers.

Syntax

Math.Min(Double, Double) has the following syntax.


public static double Min(
  double val1,
  double val2
)

Parameters

Math.Min(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.Min(Double, Double) method returns Parameter val1 or val2, whichever is smaller. If val1, val2, or both val1 and val2 are equal to NaN, NaN is returned.

Example

The following example demonstrates how to use the Min method to return and display the smaller of two variables.


using System;//w w  w.  ja v  a2  s.  c  o m

class Sample 
{
    public static void Main() 
    {
        double   xDouble1  = 6.0,  xDouble2  = 56.0;
        Console.WriteLine(Math.Min(xDouble1, xDouble2));
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version