Skip to content

Fix General scientific notation carry (10E+14 -> 1E+15) - #106

Open
arancool3000 wants to merge 1 commit into
borgar:masterfrom
arancool3000:fix/105-general-exp-carry
Open

arancool3000 wants to merge 1 commit into
borgar:masterfrom
arancool3000:fix/105-general-exp-carry

Conversation

@arancool3000

Copy link
Copy Markdown

What was wrong

In General, getExp() rounds the mantissa to 5 decimals but never checks for a carry, so values like 999999999999997 came out as 10E+14 instead of Excel's 1E+15 (also -999999999999997, 99999999999999.7, 9.9999999999997E-11).

Fix

In src/general.ts getExp(), if the rounded mantissa reaches 10, reset it to 1 and bump the exponent before building the output.

How tested

  • Added a regression test in test/ssf-general.spec.ts with the five values from the issue (fails before the fix with 10E+14, passes after).
  • npm test and the full table suite (vitest run) pass: 53080 passed; eslint and tsc --noEmit clean.

This addresses point 1 of #105 only. Points 2 (five significant digits from exponent ±99) and 3 (subnormals shown as 0) are left for a separate change.

Part of #105

AI-assisted (Claude); reviewed before submission.

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