Normalize our number encoding (#3370)

Our Number encoding consists of two parts. Firsts we convert the float
into f * 2**exp, then we uvarint encode f and exp. However, we didn't
normalize f so in theory we could end up with multiple representations
of the same number.

This changes the representation to make the f the smallest possible
integer that fulfills the formula above.

For example we used to encode 256 as (0x100, 0) but with this we instead
encode it as (0x01, 8).

Fixes #2307
This commit is contained in:
Erik Arvidsson
2017-04-10 12:20:52 -07:00
committed by GitHub
parent 0b10350af3
commit 7c4e2385ab
9 changed files with 84 additions and 34 deletions

View File

@@ -1 +1 @@
3:7.7:2i6mkbcajmnkkguethlmo929rif79r8r:c1uoqa08f12o0abqgv2lvavmppuc3kg4:m6j2e6jd69tbfk7d4hqf05ke2so64df3:2:e9v26bl5mov3mtp2vdvpb7q926oqn2dn:2
3:7.8:2i6mkbcajmnkkguethlmo929rif79r8r:c1uoqa08f12o0abqgv2lvavmppuc3kg4:m6j2e6jd69tbfk7d4hqf05ke2so64df3:2:e9v26bl5mov3mtp2vdvpb7q926oqn2dn:2