scurker / currency.js

A javascript library for handling currencies
https://currency.js.org
MIT License
3.15k stars 142 forks source link

Fails to parse and format values < 1.e-6 #470

Closed clemens-msupply closed 6 months ago

clemens-msupply commented 6 months ago

I get the following results here:

const t1 = currency(0.000001, { precision: 10 }).format(); // "$0.000001"
const t2 = currency(0.0000001, { precision: 10 }).format(); // "$0.-7"

I guess currency() tries to parse the js number converted to a string ("1e-7") which fails?

scurker commented 6 months ago

I'm unable to reproduce this, what environment is this happening in?

clemens-msupply commented 6 months ago

You are right, I missed that we are using a custom formatter... Sorry for that.