Skip to content

fix: handle exponential notation in formatNumber - #252

Open
DeoJin wants to merge 1 commit into
openexchangerates:masterfrom
DeoJin:fix/handle-exponential-format-number
Open

fix: handle exponential notation in formatNumber#252
DeoJin wants to merge 1 commit into
openexchangerates:masterfrom
DeoJin:fix/handle-exponential-format-number

Conversation

@DeoJin

@DeoJin DeoJin commented Mar 18, 2026

Copy link
Copy Markdown

Summary

  • fix oFixed() so values already represented in exponential notation are rounded correctly
  • add regression coverage for tiny positive and negative numbers in ormatNumber

Validation

ode -e "const assert=require('assert'); const a=require(process.argv[1]); assert.strictEqual(a.formatNumber(0.615,2),'0.62'); assert.strictEqual(a.formatNumber(0.614,2),'0.61'); assert.strictEqual(a.formatNumber(1.005,2),'1.01'); assert.strictEqual(a.formatNumber(1e-7,2),'0.00'); assert.strictEqual(a.formatNumber(1e-7,7),'0.0000001'); assert.strictEqual(a.formatNumber(-1e-7,7),'-0.0000001'); console.log('validation ok');" "C:\Users\Administrator.openclaw\workspace\tmp\accounting.js\accounting.js"

Closes #241.

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.

Tiny numbers lead to NaN.undefined

1 participant