amazon-ion / ion-go

A Go implementation of Amazon Ion.
https://amazon-ion.github.io/ion-docs/
Apache License 2.0
175 stars 31 forks source link

Float32 Lossless Support #101

Closed matthewh-BQ closed 4 years ago

matthewh-BQ commented 4 years ago

According to the Ion specification: http://amzn.github.io/ion-docs/docs/float.html, it's always valid to store a float as an float64, but if it fits in an float32 then that's an option too. This change checks to see if a float can be losslessly represented as a float32 and does so.

Originally this was part of the Marshal tests, but this fix can be its own PR.