Send feedback on this topic.
Teradata.Client.Provider
Division Operator (TdDecimal)
Example 



Teradata.Client.Provider Namespace > TdDecimal Structure : Division Operator
The TdDecimal that will be the enumerator.
The TdDecimal that will be the denominator.
Calculates the division of two TdDecimals.
Syntax
'Declaration
 
Public Operator /( _
   ByVal enumerator As TdDecimal, _
   ByVal denominator As TdDecimal _
) As TdDecimal
'Usage
 
public TdDecimal operator /( 
   TdDecimal enumerator,
   TdDecimal denominator
)
public:
TdDecimal operator /( 
   TdDecimal enumerator,
   TdDecimal denominator
)

Parameters

enumerator
The TdDecimal that will be the enumerator.
denominator
The TdDecimal that will be the denominator.

Return Value

The TdDecimal containing the result
Exceptions
ExceptionDescription
An attempt to divide by 0 was made.
The result has a precision greater than the TdDecimal.MaxPrecision.
Remarks
If one of the parameter is TdDecimal.Null, the result will be TdDecimal.Null.

The result of this operation will have its TdDecimal.Scale set to the maximum scale between the enumerator and denominator. For example, the result of "4 / 5" will be 0. In order to increase the scale of the result, the scale of one of the operands will need to be increased. In this example the scale for either the numerator or denominator can be increased. If TdDecimal.AdjustScale were called to increase the scale of the enumerator by 1, the result of "4.0 / 5" will be 0.8.
Example
The following are examples using the division operator.
TdDecimal enumerator;
TdDecimal denominator;
TdDecimal result;
            
enumerator = TdDecimal.Parse("1");
denominator = TdDecimal.Parse("3");
// Going to perform the operation 1 / 3.  
// result = 0, Precision = 38, Scale = 0.  
// The reason for this is that both the enumerator and denominator have a scale of 0.
result = enumerator / denominator;
Console.WriteLine("{0} / {1} = {3}", enumerator, denominator, result);
            
enumerator = new TdDecimal(1, 0, 0, 0, 4, 3);
denominator = new TdDecimal(3, 0, 0, 0, 3, 2);
// Going to perform the operation 1.000 / 2.00.
// result = 0.333, Precision = 38, Scale = 3
// The enumerator has the largest scale.
result = enumerator / denominator
Console.WriteLine("{0} / {1} = {3}", enumerator, denominator, result);
            
enumerator = new TdDecimal(1, 0, 0, 0, 1, 0);
denominator = new TdDecimal(4, 0, 0, 0, 2, 1);
// Going to perform the operation 1 / 4.0.
// result = 0.2, Precision = 38, Scale = 1
// The largest scale between the enumerator and denominator is 1.  
// Therefore, the result will only have a scale of 1.  
// The result has been truncated.
result = enumerator / denominator;
Console.WriteLine("{0} / {1} = {3}", enumerator, denominator, result);
            
enumerator = new TdDecimal(1, 0, 0, 0, 10, 5);
denominator = new TdDecimal(4, 0, 0, 0, 10, 7);
// Going to perform the operation 1.00000 / 4.0000000
// result = 0.2500000, Precision = 38, Scale = 7
// The largest scale between the enumerator and denominator is 7.
result = enumerator / denominator;
Console.WriteLine("{0} / {1} = {3}", enumerator, denominator, result);
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