feat: FixedPoint.parse — exact decimal-string round-trip (P4.1)#63
Merged
Conversation
parse("-?digits[.digits]") with 1..8 decimals, exact (no double detour),
signed accumulation so Long.MIN_VALUE round-trips, NumberFormatException on
malformed input (exponents, >8dp, whitespace, grouping), OverflowException
past 92233720368.54775807. Also fixes format() dropping the sign for values
in (-1, 0). Property test: parse(format(x)) == x over 1M random longs +
edges; canonical wire representation for money on the OMS API.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First piece of openexch/oms#39 (P4.1 money-on-the-wire): money will cross REST/WS/gRPC as exact 8-dp decimal strings, and FixedPoint gains the missing primitive — a strict, exact parser.
parse(CharSequence): grammar-?digits[.digits](1..8 decimals), no double detour, signed accumulation soLong.MIN_VALUEround-trips,NumberFormatExceptionfor anything else (exponents, 9+ decimals, whitespace, grouping, lone signs) — money precision is never silently rounded;OverflowException(the match#30 class) past the representable range.format()bug fix: values in (-1, 0) printed unsigned (-0.5→"0.50000000"). Latent for money (always positive) but fatal for a canonical round-trip.parse(format(x)) == xover 1M random longs + edge values (MIN/MAX, sub-unit negatives), exactness cases the double path cannot represent (18 significant digits), full malformed-input rejection matrix, overflow boundary at92233720368.54775807.match-common full suite green.
🤖 Generated with Claude Code