Skip to content

Binding numeric values can BigDecimal lose precision #1315

@asnare

Description

@asnare

It looks like commit c809c0c (intended to fix #1028) introduced an issue where numeric values lose precision prior to being returned as BigDecimal instances. (Feature USE_BIG_DECIMAL_FOR_FLOATS enables this; given that it's disabled for performance by default, the reason to enable it is when you specifically want to avoid precision loss.)

This issue is still present in 2.8.1 (which is where I encountered it).

Some initial discussion took place as comments on the commit. I don't know enough about the contracts involved in the parsing state, but some things that caught my eye:

  • Retrieving the parser value as a Double is where the precision loss occurs.
  • The fix was intended to deal with returning NaN/Inf, which BigDecimal doesn't support. However these aren't legal values in JSON, and there's a ALLOW_NON_NUMERIC_NUMBERS feature to allow this as extension. (Maybe the feature-check is somewhere else? I haven't looked.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions