Send feedback on this topic.
Teradata.Client.Provider
GetBytes Method (TdDecimal)
Example 



Teradata.Client.Provider Namespace > TdDecimal Structure : GetBytes Method
The binary representation of the value of this TdDecimal structure is returned as an array of bytes. The most significant byte will be the last byte in the array.
Syntax
'Declaration
 
Public Function GetBytes() As Byte()
'Usage
 
Dim instance As TdDecimal
Dim value() As Byte
 
value = instance.GetBytes()
public byte[] GetBytes()
public:
array<byte>^ GetBytes(); 

Return Value

An array of bytes is returned that is the binary representation of the value of this TdDecimal.
Exceptions
ExceptionDescription
The value of the TdDecimal is Null.
Remarks
TdDecimal uses four unsigned 32 bit integers to internally store the number. The four integers will represent the decimal as a scaled integer –the decimal point has been removed by multiplying the number by 10 to the power of the scale.
Example
The following example shows the output when GetBytes is called:
// The M indicates that the literal is a System.Decimal.
TdDecimal original = new TdDecimal(983726465.23235M);
 
Byte[] result = original.GetBytes();
 
//The scaled integer representation of 983726465.23235 is 98372646523235
//The hex representation of 98372646523235 is 0x59782AA6D163
//
//result = {0x63, 0xD1, 0xA6, 0x2A, 0x78, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
            
// This following example shows how a negative number will be represented.  Internally,
// negative numbers are stored in Two's Complement representation.
            
original = TdDecimal.Parse("-4321.91");
            
result = original.GetBytes();
            
// The scaled integer representation of -4321.91 is -432191.
// The Two's Complement of represenation of -42191 in hex is 0xFFF967C1.
//
// result = {0xC1, 0x67, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
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