Send feedback on this topic.
Teradata.Client.Provider
Round(TdDecimal,Int32) Method
Example 



Teradata.Client.Provider Namespace > TdDecimal Structure > Round Method : Round(TdDecimal,Int32) Method
The TdDecimal that will be rounded.
The decimal place where rounding will occur.
The number nearest the specified TdDecimal’s value and position is calculated.
Syntax
'Declaration
 
Public Overloads Shared Function Round( _
   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.Round(input, position)
public static TdDecimal Round( 
   TdDecimal input,
   int position
)
public:
static TdDecimal Round( 
   TdDecimal input,
   int position
) 

Parameters

input
The TdDecimal that will be rounded.
position
The decimal place where rounding will occur.

Return Value

The result of the round operation is returned as a TdDecimal.
Exceptions
ExceptionDescription
Position is less than 0 or greater than 38.
The result is not supported by TdDecimal.
Remarks

The position can only be a positive value. A positive position moves to the right of the decimal. For example, 328.5563 rounded at position 3 results in 328.556. If a position of 1 is specified a value of 328.6 is returned.

By default, the behavior is to round to MidpointRounding.ToEven. For example, the following are the results of rounding the following numbers at the third decimal position:

Value Result
12343.2343434 12343.234
12343.234534 12343.235
12343.2355 12343.236
12343.2365 12343.236
Example
The following is an example that rounds a TdDecimal at various positions:
//M indicates that the numeric literal is a System.Decimal
            
TdDecimal original = new TdDecimal(867498.23535M);
 
TdDecimal result1 = TdDecimal.Round(original, 2);
TdDecimal result2 = TdDecimal.Round(original, 4);
 
//The results will be as follows:
//  result1 = 867498.24
//  result2 = 867498.2354
            
original = new TdDecimal(867498.646525M);
            
TdDecimal result3 = TdDecimal.Round(original, 3);
TdDecimal result4 = TdDecimal.Round(original, 5);
            
//The results will be as follows:
//  result3 = 867498.647
//  result4 = 867498.64652
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
Overload List