Skip to content

fix two digit trailing zeros < 0.10 #42

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

Merged

Conversation

paulbjarne
Copy link
Contributor

Fixes two place decimal formatting after zero for < 0.10

@CLAassistant
Copy link

CLAassistant commented Jan 18, 2018

CLA assistant check
All committers have signed the CLA.

@paulbjarne paulbjarne changed the title Paulbjarne/fix trailing zeros fix two digit trailing zeros < 0.10 Jan 18, 2018
@@ -90,7 +90,9 @@ format ∷ Formatter → Number → String
format (Formatter f) num =
let
absed = Math.abs num
tens = if absed > 0.0 then Int.floor $ Math.log absed / Math.ln10 else 0
tens = if absed > 0.0
then max (Int.floor $ Math.log absed / Math.ln10) 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the issue was that Math.log for anything less then 1.0, will return negative number

@@ -118,6 +120,11 @@ format (Formatter f) num =
let
multiplier = Math.pow 10.0 $ Int.toNumber f.after
in Int.round $ leftover * multiplier
roundedWithZeros =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this part, @cryogenian can you take a look?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds zeros after comma/point and digits.

@cryogenian
Copy link
Member

@paulbjarne Thank you!

@cryogenian cryogenian merged commit 8eacf46 into purescript-contrib:master Jan 18, 2018
mjhoy added a commit to mjhoy/package-sets that referenced this pull request May 2, 2018
@mjhoy mjhoy mentioned this pull request May 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants