Skip to content

Conversation

@michaelglass
Copy link

@michaelglass michaelglass commented Feb 2, 2026

Summary

Problem

GetString was converting large integer route values (like Int64.MaxValue) to scientific notation, causing precision loss:

ctx.Request.RouteValues.Add("id", "9223372036854775807")  // Int64.MaxValue
let route = Request.getRoute ctx
route.GetString "id"  // Was: "9.223372036854776E+18", Now: "9223372036854775807"

Root Cause

The IsFloat pattern was parsing all numeric-looking strings as float64 values. For integers with more than ~15 significant digits, this caused precision loss since float64 only has 15-16 digits of precision.

Solution

Modified the IsFloat pattern to not match integer strings with more than 15 significant digits. Such values now remain as RString, preserving the original value exactly.

This doesn't break GetInt64 because it already handles RString values by parsing them directly via StringParser.parseInt64.

Test plan

  • Added unit tests for precision boundary (15 vs 16+ digit integers)
  • Added regression test for route values with Int64.MaxValue
  • All 71 existing tests pass

🤖 Generated with Claude Code.

I (the human, Michael) couldn't find any place in the contribution docs that was against this, I hope it's ok. (also: want to be transparent about our slow demise as working software devs)

Prevent integers with more than 15 significant digits from being parsed
as floats, which would lose precision. Such values now remain as strings,
preserving the original value while still allowing GetInt64 to parse them
correctly.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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