FasterXML / smile-format-specification

New home for Smile format (https://en.wikipedia.org/wiki/Smile_(data_interchange_format))
BSD 2-Clause "Simplified" License
92 stars 14 forks source link

Can smile represent JSON with large exponents (wrt Java `BigDecimal` limit) #20

Open andrewthad opened 2 years ago

andrewthad commented 2 years ago

The readme claims that

"Smile" is a binary data format that defines a binary equivalent of standard JSON data format.

From my reading of the spec, smile is not able to represent number with exponents over 2^31. For example, in JSON we could have this number:

1e10000000000

In practice, this is unlikely to matter, but I'm working on a smile codec that does not have the same limitations as Java's BigDecimal, and I'd like to be sure that I understood the spec correctly. If this is the case, it would be good to clarify somewhere that smile does not represent every json document faithfully. (or hopefully I'm wrong! and then there's one less corner case to worry about)

cowtowncoder commented 2 years ago

I think you are correct here: I had not thought of limitations that BigInteger and BigDecimal have wrt unbounded magnitude/precision. If you can suggest improvements to wording of the specification, I would be happy to get a pr against smile-specification.md (for example). I think it does make sense to be accurate with statements, and outline known cases of impossible transforms.