Zulu-Inuoe / jzon

A correct and safe(er) JSON RFC 8259 reader/writer with sane defaults.
MIT License
151 stars 14 forks source link

Implement the Schubfach Float Printer #22

Closed Zulu-Inuoe closed 1 year ago

Zulu-Inuoe commented 1 year ago

Fixes #15

This implements the Schubfach2 Floating Point Printing algorithm described by Raffaello Giulietti in the paper titled 'The Schubfach way to render doubles' available here: https://drive.google.com/file/d/1luHhyQF9zKlM8yJ1nebU0OgVYhfC6CBN/view

This is a direct port of the Scala writeFloat and writeDouble code implemented here: https://github.com/plokhotnyuk/jsoniter-scala/blob/master/jsoniter-scala-core/jvm/src/main/scala/com/github/plokhotnyuk/jsoniter_scala/core/JsonWriter.scala

Licensed at the time of writing under the MIT License.

Benefits of this change:

  1. Consistently concise floating point values across implementations
  2. About 5x faster on SBCL on default safety/speed
  3. ~1/3rd consing