'Declaration Public Function GetBytes() As Byte()
public byte[] GetBytes()
public: array<byte>^ GetBytes();
'Declaration Public Function GetBytes() As Byte()
public byte[] GetBytes()
public: array<byte>^ GetBytes();
Exception | Description |
---|---|
TdException | The value of the TdDecimal is Null. |
Five unsigned 32 bit integers are used internally to store the mantissa of a number, and a signed 16 bit integer is used to store the exponent.
In the byte array, the data for the mantissa will begin at the 0 (zero) element, and the exponent will begin at the 21 element of the array. It will take 20 bytes to represent the mantissa, and 2 bytes for the exponent. The total number of elements in the array will be 22.
When the binary representation is generated, The decimal point will be removed, and the exponent will adjusted. After this is done, the five unsigned 32 bit integers of the mantissa and the signed 16 bit of the exponent are converted to a byte array. The least significant byte of the mantissa will appear in the first element of the array.
TdNumber original = TdNumber.Parse("9.8372646523235e+99"); Byte[] result = original.GetBytes(); //The decimal point in the mantissa is removed and the exponent is adjusted // 98372646523235e+86 // //The hex representation of the mantissa is 0x59782AA6D163. This is internally represented by the //five unsigned integers as {0x2AA6D163, 0x00005978, 0x00000000, 0x00000000, 0x00000000} // //The hex representation of the exponent is 0x56. // //result = {0x63, 0xD1, 0xA6, 0x2A, 0x78, 0x59, 0x00, 0x00, 0x00, 0x00, // 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 0x56, 0x00} // This following example shows how a negative number will be represented. Internally, // negative numbers are stored in Two's Complement representation. original = TdNumber.Parse("-4.32191e-50"); result = original.GetBytes(); // The decimal point in the mantissa is removed and the exponent is adjusted // -432191e-55 // // The two's complement hex representation of the mantissa is 0xFFF967C1. This is // internally represented by the five unsigned integers as // {0xFFF967C1, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF} // The Two's Complement hex represenation of the exponent is 0xFFC9. // // result = {0xC1, 0x67, 0xF9, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC9, 0xFF}
Target Platforms: Windows 7, Windows 8, Windows 8.1, Windows 10, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2