-
Notifications
You must be signed in to change notification settings - Fork 28
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
fix two digit trailing zeros < 0.10 #42
Conversation
e.g., 2.05 with an after of 2 renders as "2.5" without this fix.
@@ -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 |
There was a problem hiding this comment.
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 = |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
@paulbjarne Thank you! |
Fixes two place decimal formatting after zero for < 0.10