charwise icon indicating copy to clipboard operation
charwise copied to clipboard

Shorter encoding for numbers (breaking change)

Open dominictarr opened this issue 7 years ago • 8 comments

@PaulBlanche I realized that numbers are encoded with a huge amount of precision. 2 is encoded as FE500M2.00000000000000000000 ... that seems unnecessary to me?

I removed that, and noticed it failed on the close random number tests

so I tried just appending a number that we know is higher than 9, but only on negative numbers. This seems to work, tests pass. cw.encode(-1)+'a' > cw.encode(-1.00000001)+'a'

dominictarr avatar May 12 '18 05:05 dominictarr

I chose '_' as the end character, since it's higher than numbers, and makes the output more readable.

dominictarr avatar May 12 '18 05:05 dominictarr

Yes indeed, numbers where encoded as "fixed length record". This was needed for the digit flipping trick to work on negative numbers.

Adding a char superior to 9 to the mantissa of a negative number should work, that's a nice idea !

PaulBlanche avatar May 13 '18 13:05 PaulBlanche

Is there any desire to merge this compact change ?

Raynos avatar Mar 10 '20 15:03 Raynos

I went ahead and publishes this breaking change by making a new package and naming it charwise-compact ( https://github.com/Raynos/charwise-compact ).

Raynos avatar Mar 10 '20 15:03 Raynos

Oh I can't remember if there was something still wrong with this? Did all the tests pass etc? Possibly I just forgot about it?

On Wed, Mar 11, 2020, 04:20 Jake Verbaten [email protected] wrote:

I went ahead and publishes this breaking change by making a new package and naming it charwise-compact ( https://github.com/Raynos/charwise-compact ).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/dominictarr/charwise/pull/9?email_source=notifications&email_token=AAB7KLXWURQBLJ4NYXGGUODRGZLDNA5CNFSM4E7REMN2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEOL3JTI#issuecomment-597144781, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAB7KLTHF4OJCV6OTWQT3WDRGZLDNANCNFSM4E7REMNQ .

dominictarr avatar Mar 10 '20 20:03 dominictarr

From what i remember, everything was ok.

PaulBlanche avatar Mar 11 '20 08:03 PaulBlanche

I suspect you either forgot about this or did not want to do any breaking changes or migrations of the key space in leveldb.

Raynos avatar Mar 11 '20 09:03 Raynos

You have reviewed your own pull request. This is pretty meta.

Raynos avatar Mar 13 '20 13:03 Raynos