Skip to content

[Repo Assist] Fix AsDecimal to support scientific notation (AllowExponent) — closes #337#623

Merged
dsyme merged 2 commits intomasterfrom
repo-assist/fix-issue-337-decimal-exponent-49edaa782c33824f
Mar 16, 2026
Merged

[Repo Assist] Fix AsDecimal to support scientific notation (AllowExponent) — closes #337#623
dsyme merged 2 commits intomasterfrom
repo-assist/fix-issue-337-decimal-exponent-49edaa782c33824f

Conversation

@github-actions
Copy link
Contributor

🤖 Repo Assist — automated bug fix (Task 3: Issue Investigation and Fix)

Summary

Fixes a bug reported in #337: CSV columns inferred as decimal silently dropped values written in scientific notation (e.g. 9.51E-05).

Root Cause

TextConversions.AsDecimal called Decimal.TryParse with NumberStyles.Currency, which does not include AllowExponent. So:

  • "7.058365954" → parsed as decimal ✅
  • "9.51E-05" → decimal fails (no exponent support) → becomes missing value

When the CSV type-inference engine samples the first N rows and they all contain plain decimal values, the column is typed as decimal. Subsequent rows with scientific-notation values then silently produce OptionalValue.Missing.

Fix

Add NumberStyles.AllowExponent to the NumberStyles flags in AsDecimal:

// Before
Decimal.TryParse(TextConversions.RemoveAdorners text, NumberStyles.Currency, cultureInfo)

// After
Decimal.TryParse(TextConversions.RemoveAdorners text, NumberStyles.Currency ||| NumberStyles.AllowExponent, cultureInfo)

This is the minimal, targeted fix requested by @dsyme in the issue.

Trade-offs

  • NumberStyles.Currency still handles currency symbols and group separators.
  • Adding AllowExponent only enables the E/e exponent notation; it doesn't allow any previously-rejected inputs other than scientific notation.
  • No behaviour change for plain decimal values.

Test Status

  • ✅ Added regression test Decimal columns accept scientific notation values (regression #337) in Frame.fs
  • ✅ All 272 Frame tests pass
  • ✅ Build succeeded with 0 errors

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@30f2254f2a7a944da1224df45d181a3f8faefd0d

…337

The Decimal.TryParse call in TextConversions.AsDecimal used NumberStyles.Currency,
which does not include AllowExponent. As a result, values like '9.51E-05' would
fail to parse as decimal and silently become missing values when a CSV column was
inferred as decimal (because earlier sampled rows contained plain decimal values).

Fix: add NumberStyles.AllowExponent to the flags so decimal parsing now accepts
both plain and scientific-notation decimal literals.

Also adds a regression test verifying that a CSV with scientific-notation values
in a decimal-inferred column parses correctly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review March 15, 2026 23:18
@dsyme dsyme merged commit 30c9f7c into master Mar 16, 2026
2 checks passed
@dsyme dsyme deleted the repo-assist/fix-issue-337-decimal-exponent-49edaa782c33824f branch March 16, 2026 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant