# Decimal::Truncate Method

.NET Framework 4.5

Returns the integral digits of the specified Decimal; any fractional digits are discarded.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

## Syntax

```public:
static Decimal Truncate(
Decimal d
)
```

#### Parameters

d
Type: System::Decimal

The decimal number to truncate.

#### Return Value

Type: System::Decimal
The result of d rounded toward zero, to the nearest whole number.

## Remarks

This method rounds d toward zero, to the nearest whole number, which corresponds to discarding any digits after the decimal point.

## Examples

The following code example uses the Truncate method to discard the fractional digits of several Decimal values.

```// Example of the Decimal::Negate, Decimal::Floor, and
// Decimal::Truncate methods.
using namespace System;

// Display Decimal parameters and the method results.
void ShowDecimalFloorNegTrunc( Decimal Argument )
{
String^ dataFmt = "{0,-30}{1,26}";
Console::WriteLine();
Console::WriteLine( dataFmt, "Decimal Argument", Argument );
Console::WriteLine( dataFmt, "Decimal::Negate( Argument )", Decimal::Negate( Argument ) );
Console::WriteLine( dataFmt, "Decimal::Floor( Argument )", Decimal::Floor( Argument ) );
Console::WriteLine( dataFmt, "Decimal::Truncate( Argument )", Decimal::Truncate( Argument ) );
}

int main()
{
Console::WriteLine( "This example of the \n"
"  Decimal::Negate( Decimal ), \n"
"  Decimal::Floor( Decimal ), and \n"
"  Decimal::Truncate( Decimal ) \n"
"methods generates the following output." );

// Create pairs of Decimal objects.
ShowDecimalFloorNegTrunc( Decimal::Parse( "0" ) );
ShowDecimalFloorNegTrunc( Decimal::Parse( "123.456" ) );
ShowDecimalFloorNegTrunc( Decimal::Parse( "-123.456" ) );
ShowDecimalFloorNegTrunc( Decimal(1230000000,0,0,true,7) );
ShowDecimalFloorNegTrunc( Decimal::Parse( "-9999999999.9999999999" ) );
}

/*
This example of the
Decimal::Negate( Decimal ),
Decimal::Floor( Decimal ), and
Decimal::Truncate( Decimal )
methods generates the following output.

Decimal Argument                                       0
Decimal::Negate( Argument )                            0
Decimal::Floor( Argument )                             0
Decimal::Truncate( Argument )                          0

Decimal Argument                                 123.456
Decimal::Negate( Argument )                     -123.456
Decimal::Floor( Argument )                           123
Decimal::Truncate( Argument )                        123

Decimal Argument                                -123.456
Decimal::Negate( Argument )                      123.456
Decimal::Floor( Argument )                          -124
Decimal::Truncate( Argument )                       -123

Decimal Argument                            -123.0000000
Decimal::Negate( Argument )                  123.0000000
Decimal::Floor( Argument )                          -123
Decimal::Truncate( Argument )                       -123

Decimal Argument                  -9999999999.9999999999
Decimal::Negate( Argument )        9999999999.9999999999
Decimal::Floor( Argument )                  -10000000000
Decimal::Truncate( Argument )                -9999999999
*/
```

## Version Information

#### .NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

#### .NET Framework Client Profile

Supported in: 4, 3.5 SP1

#### Portable Class Library

Supported in: Portable Class Library

#### .NET for Windows Store apps

Supported in: Windows 8

#### .NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8

## Platforms

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.