Mono Class Library: System.Math Overview | Members

System.Math.Floor Method

Returns the largest integer less than or equal to the specified double.

public static double Floor (double d)

Parameters

d
A double .

Returns

A double containing the value of the largest integer less than or equal to d. If d is equal to double.NaN, double.NegativeInfinity, or double.PositiveInfinity, that value is returned..

Remarks

The behavior of this method follows IEEE Standard 754, section 4.

Example

The following example demonstrates using the Math.Floor(double) method.

C# Example

using System;

public class MathFloorExample
{

   public static void Main()
   {

      Double d1 = Math.Floor(3.4);
      Double d2 = Math.Floor(-3.4);
      Console.WriteLine("Math.Floor(3.4) returns {0}", d1);
      Console.WriteLine("Math.Floor(-3.4) returns {0}", d2);

   }

}

The output is

Math.Floor(3.4) returns 3
Math.Floor(-3.4) returns -4

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0