Send feedback on this topic.
Teradata.Client.Provider
Truncate Method
Example 



Teradata.Client.Provider Namespace > TdDecimal Structure : Truncate Method
The TdDecimal structure to be truncated.
The decimal position to which the number will be truncated.
Truncates the specified TdDecimal structure to a specified decimal position.
Syntax
'Declaration
 
Public Shared Function Truncate( _
   ByVal input As TdDecimal, _
   ByVal position As Integer _
) As TdDecimal
'Usage
 
Dim input As TdDecimal
Dim position As Integer
Dim value As TdDecimal
 
value = TdDecimal.Truncate(input, position)
public static TdDecimal Truncate( 
   TdDecimal input,
   int position
)
public:
static TdDecimal Truncate( 
   TdDecimal input,
   int position
) 

Parameters

input
The TdDecimal structure to be truncated.
position
The decimal position to which the number will be truncated.

Return Value

The truncated number
Exceptions
ExceptionDescription
The position is out of the range of valid values.
Remarks

A TdDecimal of TdDecimal.Null will return as TdDecimal.Null.

Truncation will only occur in the fractional part (digits to the left of decimal point) of a number. Therefore, position must be greater than or equal to 0.

Example

The following is an example of truncating a number:

TdDecimal value = TdDecimal.Parse("10242954.9352");
              
// Truncating at position 2 results in 10242954.93
TdDecimal result = TdDecimal.Truncate(value, 2);
            
// Truncating at position 0 reslts in 10242954
result = TdDecimal.Truncate(value, 0);
            
try
{
    // An ArgumentOutOfRangeException will be thrown if a negative value for position is specified.
    result = TdDecimal.Truncate(value, -1);
}
catch (ArgumentOutOfRangeException)
{
    Console.WriteLine("A negative number cannot be specified for the position");
}
Requirements

Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019

See Also

Reference

TdDecimal Structure
TdDecimal Members