Mono Class Library: System.Decimal Overview | Members

System.Decimal.Truncate Method

Rounds a decimal value towards zero, to the closest integer value.

public static decimal Truncate (decimal d)

Parameters

d
The decimal to truncate.

Returns

The decimal result of truncating d . the scale of the result is 0.

Remarks

Documentation for this section has not yet been entered.

Example

The following example demonstrates using the decimal.Truncate(decimal) method.

C# Example

using System;
class MyClass {
public static void Main() {
 decimal d1 = 1234.56789m;
 decimal d2 = -1234.56789m;
 Console.WriteLine("{0} truncated is {1}", d1, Decimal.Truncate(d1));
 Console.WriteLine("{0} truncated is {1}", d2, Decimal.Truncate(d2));
}
}

The output is

1234.56789 truncated is 1234
-1234.56789 truncated is -1234

Requirements

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