Skip to content

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
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

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