Skip to content

fix: out-of-range double literals read as infinity, printed doubles round-trip - #113

Merged
skydread1 merged 5 commits into
developfrom
fix/reader-double-out-of-range
Jul 30, 2026
Merged

fix: out-of-range double literals read as infinity, printed doubles round-trip#113
skydread1 merged 5 commits into
developfrom
fix/reader-double-out-of-range

Conversation

@skydread1

@skydread1 skydread1 commented Jul 30, 2026

Copy link
Copy Markdown
Member

Closes #111, Closes #112

  • MatchNumber catches OverflowException and saturates to an infinity from the leading sign, rather than failing the read. Applied in LispReader, EdnReader and nostrand's ArgumentReader, which hold identical copies.
  • fp-str formats with the "R" round-trip specifier and InvariantCulture instead of (str x), so a printed double reads back as the same value.
  • Refreshed Clojure.dll and clojure.core_print.clj.dll in the committed deploy dirs.
  • Added a read-print smoke suite covering both fixes on the AOT path.

…f failing (#111)

Wrap the Double.Parse call in MatchNumber's float branch in a
try/catch (OverflowException) returning Double.NegativeInfinity or
Double.PositiveInfinity per the leading sign. Catching only that type keeps
FormatException on a malformed literal; underflow already returns zero
without throwing, so nothing but overflow reaches the fallback.

Applied to all three copies of MatchNumber: LispReader, EdnReader and
nostrand's ArgumentReader, each in place because upstream keeps these
readers independent.
#112)

Change fp-str's binding from (str x) to
(.ToString x "R" CultureInfo/InvariantCulture). "R" emits as many digits as
Double.Parse needs to return the identical value; the default emits 15
significant digits and loses precision. The explicit culture replaces the
ambient one, which could emit a comma decimal separator.

fp-str backs both the Double and Single print methods.
@skydread1 skydread1 self-assigned this Jul 30, 2026
…suite (#111 #112)

Add a read-print suite and register it in runner.clj. IL2CPP supplies its
own Double.ToString(string, IFormatProvider) and exception handling, so the
Mono result does not cover the AOT path.
@skydread1
skydread1 force-pushed the fix/reader-double-out-of-range branch from c274afa to ef75236 Compare July 30, 2026 03:30
@skydread1
skydread1 merged commit 56f4b84 into develop Jul 30, 2026
1 check passed
@skydread1
skydread1 deleted the fix/reader-double-out-of-range branch July 30, 2026 03:36
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.

Printed doubles do not read back as the same value Out-of-range double literals fail to read instead of becoming infinity

1 participant