C# Math Min(Single, Single)
Description
Math Min(Single, Single)
returns the smaller of two single-precision
floating-point numbers.
Syntax
Math.Min(Single, Single)
has the following syntax.
public static float Min(
float val1,
float val2
)
Parameters
Math.Min(Single, Single)
has the following parameters.
val1
- The first of two single-precision floating-point numbers to compare.val2
- The second of two single-precision floating-point numbers to compare.
Returns
Math.Min(Single, Single)
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.
// This example demonstrates Math.Min()
using System;
/*from w w w . ja v a 2s. c o m*/
class Sample
{
public static void Main()
{
float xSingle1 = 5.0f, xSingle2 = 55.0f;
Console.WriteLine( Math.Min(xSingle1, xSingle2));
}
}
The code above generates the following result.