Formats for NUMERIC and DECIMAL data types vary as a function of precision.
NUMERIC(4,2): 1234
NUMERIC(6,4): 123400
NUMERIC(8,4): 00123400
NUMERIC(12,6): 000012340000
NUMERIC(16,8): 0000001234000000
If precision <= 4, binary format is identical to native operating system binary format for 2-byte integer quantity.
If precision is between 5 and 9, binary format is identical to native operating system binary format for a 4-byte integer quantity.
If precision is between 10 and 18, binary format is identical to native operating system binary format for an 8-byte integer quantity.
struct { unsigned char sign; // sign 1 for +, 0 for - unsigned char ndig; // # digits unsigned char exp; // exponent unsigned char erracc; // should be 0 unsigned short digits[80]; };
sign = 1 ndig = 0 erracc = 0 exp = 0
lower order digit = digit[i] & 0x00FF
high order digit = digit[i] & 0xFF00
0x0101 0x5000 0x0064 0x0000 0x0000 ...... Sign = 0x01 Number digits = 0x01 Exponent = 0x50 Erracc = 0x00 Digits = 0x0064
0x0102 0x5000 0x0ad1 0x0003 0x0000 0x0000 .... Sign = 0x01 Number digits = 0x02 Exponent = 0x50 Erracc = 0x00 Digits = 0x0ad1 0x0003
0x0ad1 = 2769 0x0003 = 3