-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Safe number convertion ? #1317
Comments
More safe number conversion question with number attribute : #1583 |
This issue aims to centralize very different problem related to number conversion. In this comment, I talk only about : Maximize JSON/SenML-JSON interoperability following RFC Should we limit range and precision of numbers to IEEE 754 binary64 (double precision) to maximize interoperability by default ? (See #916 for more details) (probably SenML-CBOR is not concerned by that) The 2 points from RFC are :
Note that : A double uses 52 bits for the mantissa, which translates to about 15-17 decimal digits of precision. If we want to strictly follow RFC recommendation, I understand that we should avoid to send number with too big mantissa or exponent in way we ensure it fit in a double. And also probably not accept those number. The obvious benefit of that would be to increase interoperability.
The major drawbacks of following those recommendation :
Of course, this will only happen for very large number (> 2^53 or <-2^53), so maybe only for a few use cases. So I see possible 3 mode :
Which of this mode should we implement ? My personal option, this option seems ok to me :
Any opinion ? |
(Not directly linked to comment above : #1692 aims to detect Number To double precision loss in conversion) |
After some discussion with @jvermillard Not so obvious that 1 and 2 is needed.
|
I will use this issue as a kind of bookmark to store all information about number handling issues/questions in Leshan.
In a general way, our encoder/decoder have to deal with different kind of number encoding.
By default, we should be sure those conversions are done without any information lost.
We begin to do that in
NumberUtil
class but not yet fully done.Maximize JSON/CBOR interoperability ?
Should we limit range and precision of numbers to IEEE 754 binary64 (double precision) to maximize interoperability by default ?
This would affect old JSON / SenML-JSON / SenML-CBOR encoding :
It seems this is a real world question in JSON world : FasterXML/jackson-databind#911
Some links about how to handle this kind of conversion safely :
Non exhaustive list of Leshan issue relative to that :
The text was updated successfully, but these errors were encountered: