Skip to content

feat: FixedPoint.parse — exact decimal-string round-trip (P4.1)#63

Merged
emrebulutlar merged 1 commit into
mainfrom
p41-fixedpoint-parse
Jul 4, 2026
Merged

feat: FixedPoint.parse — exact decimal-string round-trip (P4.1)#63
emrebulutlar merged 1 commit into
mainfrom
p41-fixedpoint-parse

Conversation

@emrebulutlar

Copy link
Copy Markdown
Member

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 so Long.MIN_VALUE round-trips, NumberFormatException for 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.
  • Tests: parse(format(x)) == x over 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 at 92233720368.54775807.

match-common full suite green.

🤖 Generated with Claude Code

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>
@emrebulutlar
emrebulutlar merged commit 751cedd into main Jul 4, 2026
2 checks passed
@emrebulutlar
emrebulutlar deleted the p41-fixedpoint-parse branch July 4, 2026 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant