Open phemmer opened 6 years ago
After looking at this for a little bit, deferring unmarshal would only solve a small number of the uses of float64
. So what about replacing float64
with shopspring decimal or cockroachdb decimal.
Will work with Bitfinex on this feature request. For now, adding to backlog.
float64
is used in a few places in the v2 code. Aside from the obvious case of fractional precision loss, floats are also imprecise for large numbers: https://play.golang.org/p/Xht8UkOf7q which could be relevant here if channel IDs ever become large, and is more likely to soon be relevant for order IDs (which are already up to 6129454770 as of the time of this issue).For the bodies (pricing & amounts), I think unmarshalling of the value should be deferred (e.g. via
json.RawMessage
), and then converted to float only if the consumer is OK with the imprecision. Otherwise the raw value should be provided as a[]byte
.