C# Decimal Floor

Description

Decimal Floor rounds a specified Decimal number to the closest integer toward negative infinity.

Syntax

Decimal.Floor has the following syntax.


public static decimal Floor(
  decimal d
)

Parameters

Decimal.Floor has the following parameters.

  • d - The value to round.

Returns

Decimal.Floor method returns If d has a fractional part, the next whole Decimal number toward negative infinity that is less than d. -or- If d doesn't have a fractional part, d is returned unchanged. Note that the method returns an integral value of type Decimal.

Example

The following example illustrates the Floor method.


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

public class Example
{
   public static void Main()
   {
      Console.WriteLine(Decimal.Floor(-3.9m));
      Console.WriteLine(Decimal.Floor(3.9m));
   }
}

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