Blaze 0.0.1
The ultra high-performance JSON Schema evaluator
Loading...
Searching...
No Matches
Number Encodings

Classes

struct  sourcemeta::blaze::DOUBLE_VARINT_TUPLE
 The encoding consists of a sequence of two integers: The signed integer that results from concatenating the integral part and the decimal part of the number, if any, as a ZigZag-encoded Base-128 64-bit Little Endian variable-length unsigned integer; and the position of the decimal mark from the last digit of the number encoded as a Base-128 64-bit Little Endian variable-length unsigned integer. More...
struct  sourcemeta::blaze::NUMBER_VARINT_TUPLE
 The encoding consists of a sequence of two integers. The first is the signed coefficient of the number as a ZigZag-encoded Base-128 64-bit Little Endian variable-length unsigned integer. The second is the base-10 exponent that the coefficient is scaled by, ZigZag-encoded and shifted left by one bit, whose least significant bit is set when the number is an arbitrary-precision decimal rather than a double, as a Base-128 64-bit Little Endian variable-length unsigned integer. More...

Detailed Description


Class Documentation

◆ sourcemeta::blaze::DOUBLE_VARINT_TUPLE

struct sourcemeta::blaze::DOUBLE_VARINT_TUPLE

The encoding consists of a sequence of two integers: The signed integer that results from concatenating the integral part and the decimal part of the number, if any, as a ZigZag-encoded Base-128 64-bit Little Endian variable-length unsigned integer; and the position of the decimal mark from the last digit of the number encoded as a Base-128 64-bit Little Endian variable-length unsigned integer.

Options

None

Conditions

None

Examples

Given the input value 3.14, the encoding results in the variable-length integer 628 (the ZigZag encoding of 314) followed by the variable-length unsigned integer 2 (the number of decimal digits in the number).

+------+------+------+
| 0xf4 | 0x04 | 0x02 |
+------+------+------+

Real numbers that represent integers are encoded with a decimal mark of zero. Given the input value -5.0, the encoding results in the variable-length integer 9 (the ZigZag encoding of -5) followed by the variable-length unsigned integer 0.

+------+------+
| 0x09 | 0x00 |
+------+------+

◆ sourcemeta::blaze::NUMBER_VARINT_TUPLE

struct sourcemeta::blaze::NUMBER_VARINT_TUPLE

The encoding consists of a sequence of two integers. The first is the signed coefficient of the number as a ZigZag-encoded Base-128 64-bit Little Endian variable-length unsigned integer. The second is the base-10 exponent that the coefficient is scaled by, ZigZag-encoded and shifted left by one bit, whose least significant bit is set when the number is an arbitrary-precision decimal rather than a double, as a Base-128 64-bit Little Endian variable-length unsigned integer.

Unlike DOUBLE_VARINT_TUPLE, this encoding covers both of the numeric representations that a JSON document may hold, and the schema-driven mode relies on that: a schema that permits a number cannot tell which of the two an instance will carry, so the distinction travels with the data. The exponent is signed so that magnitudes a decimal mark cannot reach, such as 1e300, remain within the encoding.

Options

None

Conditions

The coefficient must fit in a signed 64-bit integer, which holds every number of up to 19 significant digits

Examples

Given the decimal input value 2.1, the encoding results in the variable-length integer 42 (the ZigZag encoding of 21) followed by the variable-length unsigned integer 3 (the ZigZag encoding of the exponent -1, shifted left by one bit, with the decimal bit set).

+------+------+
| 0x2a | 0x03 |
+------+------+

Given the double input value 3.14, the encoding results in the variable-length integer 628 (the ZigZag encoding of 314) followed by the variable-length unsigned integer 6 (the ZigZag encoding of the exponent -2, shifted left by one bit, with the decimal bit clear).

+------+------+------+
| 0xf4 | 0x04 | 0x06 |
+------+------+------+