Skip to content

Track exact decimal literals and numeric reader compatibility #1293

Closed

Description

@PHJ2000

Following the agreed split in #1290 (comment), this tracks the decimal-literal and reader work removed from #1290 and #1291. Those PRs now address exact integral operands and values already supplied as BigDecimal, without changing the default readers.

For example, with {"multipleOf":2}, the decimal literal 9007199254740993.0 can already be rounded by a default reader before validation. The integral spelling 9007199254740993 is covered by the narrowed fix for #1286. The decimal spelling needs a separate reader design.

The follow-up needs to cover:

  • Exact decimal literals in JSON and YAML, including string/stream input, location-aware readers, caller-supplied mappers, and the public mapper factories. Explicit YAML floats such as !!float 1_000 must retain their parsing behavior.
  • Numeric node equality across multipleOf, bounds, const, enum, and uniqueItems, including FloatNode conversion and equal BigDecimal values with different scales. Location-aware reading must use the same numeric semantics.
  • Compatibility of 0.0 and -0.0: node type, sign, serialization, defaults, and error text. The previous reader prototype changed these, so an exactness fix needs explicit compatibility decisions and tests.
  • Parsing cost for ordinary machine-generated doubles and long decimal literals on the supported JDKs. Avoid repeated text copies/conversions or parsing an arbitrary-length exponent as a BigInteger.
  • Type-loose numeric strings whose exponents exceed BigDecimal's range. The narrowed PRs keep the existing NumberFormatException behavior; a future fix should define bounded parsing and preserve the protected conversion hooks.
  • Policy for zero, negative, and non-finite schema divisors and bounds. The narrowed PRs do not introduce new SchemaException checks: zero divisors remain ignored and finite negative divisors retain their existing divisibility behavior.
  • Count limits outside the int range, including minContains/maxContains, consistent handling across count keywords, and accurate error messages.

The reader regressions listed above were found in the earlier PR prototype; they are constraints for a replacement design, not a claim that all are bugs in the unchanged readers. Details of the deferred findings are in #1290 (comment).

Activity

  1. PHJ2000 commented on Oct 10, 2026

    @PHJ2000
    ContributorAuthor

    I’d like to start working on the follow-up items in #1293 and want to check how you’d prefer to organize them. Would you prefer separate issues linked from here, or multiple focused PRs against this issue? Either approach works for me.

  2. stevehu commented on Oct 13, 2026

    @stevehu
    Contributor

    Thanks for offering to take these on, and for seeing #1290/#1291 through. Both are now merged (47d2fe6 on master, f2387c2 on 2.x).

    I'd prefer separate focused issues linked from here, each fixed by its own small PR pair (master + 2.x, merged together as before). Let's keep #1293 as the tracking issue with a checklist. Separate issues keep each review small and let the risky reader work move at its own pace without blocking the simpler items.

    Two items already have issues, so please link these rather than opening new ones:

    Suggested order:

    1. Small, independent items first: multipleOf: divisor shown as 1E+2 in messages; 2.x throws on a divisor that overflows double #1328, count limits outside the int range (minContains/maxContains and the other count keywords), bounded parsing for type-loose numeric strings with huge exponents, and the policy for zero/negative/non-finite divisors and bounds.

    2. Share numeric equality across const, enum and uniqueItems; cache numberKind in uniqueItems #1307 next.

    3. Exact decimal literals in the readers last. It changes what the default and public mappers produce, so before writing code, please post a short design in its issue. It should cover:

      • which readers and factories change, and whether the new behaviour is opt-in or the default;
      • the decisions for 0.0/-0.0 and YAML !!float;
      • how location-aware reading stays consistent;
      • parse-cost numbers for ordinary doubles on the supported JDKs.

      Once we agree on the design, the implementation review will go much faster.

    Changes that alter validation results with the default settings need a CHANGELOG entry. Ones that only affect custom validators are fine in a minor release, with a note.

  3. PHJ2000 commented on Oct 14, 2026

    @PHJ2000
    ContributorAuthor

    Thanks for the guidance, and for reviewing #1290 and #1291 through all the rounds. I’ll follow the approach you suggested and start by looking into #1328, with separate PRs for master and 2.x. For the reader changes, I’ll post a short design for discussion before starting the implementation.

  4. PHJ2000 commented on Oct 19, 2026

    @PHJ2000
    ContributorAuthor

    Thanks for reviewing and merging #1329 and #1330. I’ve opened #1334 for count and length limits beyond the int range. The same narrowing conversion affects all eight related keywords. I’ll take this up next and prepare separate fixes for master and 2.x.

  5. PHJ2000 commented on Oct 23, 2026

    @PHJ2000
    ContributorAuthor

    Hi @stevehu, I’ve reviewed #1341 and #1342 and posted my verification results in #1334. I’d like to continue with the remaining follow-ups.

    I noticed #1293 was closed as completed. We previously discussed keeping it as the tracking issue, and there are still remaining items, including #1307, bounded parsing for type-loose numeric strings with huge exponents, divisor/bound policies, and the exact-decimal reader design.

    Could we reopen #1293 to track those items while addressing them through separate focused issues and PR pairs, as discussed? If you’d prefer to track the remaining work only in separate issues, I’m happy to follow that approach.

  6. stevehu commented on Oct 23, 2026

    @stevehu
    Contributor

    Closing this tracking issue and moving the one remaining piece to #1357.

    Done from this list:

    Remaining: the default readers still round decimal-spelled numbers beyond double precision for multipleOf and numeric bounds (for example 9007199254740993.0). That reader design, together with the 0.0/-0.0, parsing-cost and YAML/mapper constraints from this issue, is now #1357. The divisor and bound policy questions are not part of it; they keep their current behaviour unless someone opens a separate decision.

    @PHJ2000, thank you for the follow-ups. #1357 is the item to pick up if you would like to continue; as agreed, a short design note there before the implementation would be best.

    🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions