Skip to content

2 digits after decimal, less than 0.10, is improperly formatted #41

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
paulbjarne opened this issue Jan 17, 2018 · 5 comments
Closed

2 digits after decimal, less than 0.10, is improperly formatted #41

paulbjarne opened this issue Jan 17, 2018 · 5 comments

Comments

@paulbjarne
Copy link
Contributor

I am using purescript-formatters to display USD formatted numbers. I am running into a subtle bug where numbers with decimal between 0.00 and 0.10 (i.e. $1.01 or $1.09) does not get formatted properly. An example of this bug is below -

formattedNumber :: String
formattedNumber =
  let 
    fmtter = Formatter
      { comma: false
      , before: 0
      , after: 2
      , abbreviations: false
      , sign: false
      }
  in 
    format fmtter 1.09

-- formattedNumber == "1.9"

Here is a link to a branch with a failing test demonstrating this.

I may have a PR that can fix this upcoming.

@safareli
Copy link
Contributor

safareli commented Jan 18, 2018

I may have a PR that can fix this upcoming.

Looking forward

There are also #30 #16, all of which are related to the issue.

@garyb
Copy link
Member

garyb commented Jan 18, 2018

#30 is different as that relates to the date formatter :)

@safareli
Copy link
Contributor

Correct, I saw digit and thought it was also related to numbers :d

@paulbjarne
Copy link
Contributor Author

#42 does the trick for us.

We made the change on a much older version (v1.0.0 😬), but it rebased cleanly against current master. I also added the test that I linked to above (failing before these changes, but now passing).

@paulbjarne
Copy link
Contributor Author

This should be fixed with #42 getting merged, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants