Skip to content

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

@paulbjarne

Description

@paulbjarne

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions