Skip to content

fix: pick random scientific notation#491

Open
wusctong wants to merge 2 commits intoscratchfoundation:developfrom
wusctong:fix/pick-random-scientific-notation
Open

fix: pick random scientific notation#491
wusctong wants to merge 2 commits intoscratchfoundation:developfrom
wusctong:fix/pick-random-scientific-notation

Conversation

@wusctong
Copy link

Resolves

Fix #160

Proposed Changes

  • Updated Cast.isInt string branch to handle scientific notation: if the string contains an e, parse it numerically to check if it's truly a whole number, otherwise fall back to the dot check.
  • Updated the existing test for '0.1e10' from false to true, since 0.1e10 equals 1000000000 which is a whole number.

Reason for Changes

Cast.isInt only checked for a . to decide if a string was an integer. This broke with scientific notation — 5e-1 has no dot but is 0.5 (a float), causing pick random (5e-1) to (10) to return offset values like 1.5, 3.5 instead of proper floats.

Test Coverage

Updated util_cast.js — changed cast.isInt('0.1e10') expected value from false to true, since 0.1e10 (1000000000) is a whole number and should be treated as an int.

@wusctong wusctong requested a review from a team as a code owner March 22, 2026 13:15
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.

pick random () to () integer(‐ish) output with scientific notation

1 participant