C# Math Max(Single, Single)

Description

Math Max(Single, Single) returns the larger of two single-precision floating-point numbers.

Syntax

Math.Max(Single, Single) has the following syntax.


public static float Max(
  float val1,
  float val2
)

Parameters

Math.Max(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.Max(Single, Single) method returns Parameter val1 or val2, whichever is larger. If val1, or 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.


using System;/* www. j  a  va  2  s.c om*/

class Sample 
{
    public static void Main() 
    {
        float    xSingle1  = 5.0f, xSingle2  = 55.0f;
        Console.WriteLine(Math.Max(xSingle1, xSingle2));
    }
}

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