You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current code from the master parses floats with rounding where error ~1ULP that is greater than expected ~0.5ULP of java.lang.Float.valueOf().
The rounding error can be easy reproduced when parsing string representation of some values with number of digits greater than usually used for floats.
Thank you for reporting!
Since BORER's API differs from what Jsoniter offers (essentially it's a hybrid between AST/DOM-based parsing and Jsoniter's direct, zero look-ahead parsing approach) its JSON parser does not know, at the time it comes across a JSON number literal, what model type this number is eventually going to be converted to.
Converting certain "easy" numbers to Double on the spot is no problem and much faster than simply always parsing decimal numbers as a String and offloading the actual number parsing to java.lang.Double.parseDouble. However, for 32-bit Float values this can indeed result in the small inaccuracy you are rightfully describing in this ticket.
IMHO the best solution here is to add a config parameter readDecimalNumbersOnlyAsNumberStrings, defaulting to false, which can be enabled if this small inaccuracy for 32-bit Float values becomes a problem in the specific use case.
By default the parser will therefore stay in the normal, faster parsing mode with Double as intermediate carrier for Float.
Current code from the master parses floats with rounding where error ~1ULP that is greater than expected ~0.5ULP of
java.lang.Float.valueOf()
.The rounding error can be easy reproduced when parsing string representation of some values with number of digits greater than usually used for floats.
The detailed explanation is in this comment
The following code can print lot of such numbers after increasing number of iterations:
I think it should be documented if there are no other option available.
The text was updated successfully, but these errors were encountered: