I have been reading
- X.690 "Information technology – ASN.1 encoding rules: Specification of Basic Encoding Rules (BER), Canonical Encoding Rules (CER) and Distinguished Encoding Rules (DER)"
In particular, §8.5.6.4 (d), concerning a binary encoding of REAL values with a variable length mantissa and exponent, reads as follows:
"if bits 2 to 1 are 11, then the second contents octet encodes the number of octets, X say, (as an unsigned binary number) used to encode the value of the exponent, and the third up to the (X plus 3)th (inclusive) contents octets encode the value of the exponent as a two's complement binary number; the value of X shall be at least one; the first nine bits of the transmitted exponent shall not be all zeros or all ones."
This is inconsistent, as the octets from "the third up to the (X plus 3)[rd]" is actually X+1 octets.
Is anyone able to clarify this section?
I assume that it should read either
"...then the second contents octet encodes one less than the number of octets, X say,..."
or
"...the third up to the (X plus 2)nd (inclusive) contents octets..."
And, is the minimum value of X really 1, or is it 0 meaning 1 octet?
ADDENDUM: If anyone can provide me with some test data of variously BER-encoded values (octet strings with their meanings) that would be helpful.
What I have so far is
- 09 00 = 0 (zero)
- 09 01 40 = +INF (infinity)
- 09 01 41 = -INF
- 09 08 03 2b 31 2e 30 65 2b 30 = "+1.0e+0" = 1.0 (exact decimal)
- 09 05 80 fe 55 55 55 = 1398101.25 (binary, 0x555555 * 2^-2)
An example I'm not sure of is:
- ? 09 06 83 00 fc 00 00 01 = 0.0625 (binary, 0x000001 * 2^-4) ?
Also, there seems to be no encoding defined for NaN (not a number).