If an opcode has a high nibble of 0x7_
, it represents a decimal. Low nibble values indicate
the number of trailing bytes used to encode the decimal.
The body of the decimal is encoded as a FlexInt
representing its exponent, followed by a FixedInt
representing its coefficient. The width of the coefficient is the total length of the decimal encoding minus the length
of the exponent. It is possible for the coefficient to have a width of zero, indicating a coefficient of 0
. When
the coefficient is present but has a value of 0
, the coefficient is -0
.
Decimal values that require more than 15 bytes can be encoded using the variable-length decimal opcode: 0xF7
.
0xEB 0x03
represents null.decimal
.
┌──── Opcode in range 70-7F indicates a decimal
│┌─── Low nibble 0 indicates a zero-byte
││ decimal; 0d0
70
┌──── Opcode in range 70-7F indicates a decimal
│┌─── Low nibble 2 indicates a 2-byte decimal
││
72 01 07
| └─── Coefficient: 1-byte FixedInt 7
└─── Exponent: FlexInt 0
┌──── Opcode in range 70-7F indicates a decimal
│┌─── Low nibble 2 indicates a 2-byte decimal
││
72 FD 7F
| └─── Coefficient: FixedInt 127
└─── Exponent: 1-byte FlexInt -2
┌──── Opcode F7 indicates a variable-length decimal
│
F7 05 FD 7F
| | └─── Coefficient: FixedInt 127
| └───── Exponent: 1-byte FlexInt -2
└─────── Decimal length: FlexUInt 2
┌──── Opcode in range 70-7F indicates a decimal
│┌─── Low nibble 1 indicates a 1-byte decimal
││
71 07
└────── Exponent: FlexInt 3; no more bytes follow, so the coefficient is implicitly 0
┌──── Opcode in range 70-7F indicates a decimal
│┌─── Low nibble 2 indicates a 2-byte decimal
││
72 07 00
| └─── Coefficient: 1-byte FixedInt 0, indicating a coefficient of -0
└────── Exponent: FlexInt 3
┌──── Opcode 0xEB indicates a typed null; a byte follows specifying the type
│ ┌─── Null type: decimal
│ │
EB 03