C# Math Floor(Decimal)

Description

Math Floor(Decimal) returns the largest integer less than or equal to the specified decimal number.

Syntax

Math.Floor(Decimal) has the following syntax.


public static decimal Floor(
  decimal d
)

Parameters

Math.Floor(Decimal) has the following parameters.

  • d - A decimal number.

Returns

Math.Floor(Decimal) method returns The largest integer less than or equal to d. Note that the method returns an integral value of type Math.

Example

The following example illustrates the Math.Floor(Decimal) method and contrasts it with the Ceiling(Decimal) method.


using System;//from   www.  j av a 2s  .  c  o m

public class MainClass{
  public static void Main(String[] argv){  
   Console.WriteLine(Math.Floor(1.2M));
    

  }
}

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