Skip to content

Print a Float in the bill text with two decimals instead of a whole number - #1307

Open
Thayorns wants to merge 1 commit into
zerocracy:masterfrom
Thayorns:1219
Open

Thayorns wants to merge 1 commit into
zerocracy:masterfrom
Thayorns:1219

Conversation

@Thayorns

Copy link
Copy Markdown
Contributor

Since the fix for #1026, Fbe::Award::Bill#line rounded every Float in ${...} to a whole number. That removed the floating point noise, but it also turned a rate of 0.05 into 0, so the bill said "at 0 points each" while the bylaw of the same policy said 0.05, as #1219 shows.

Now a Float in the text of a bill line is rounded to two decimals, and the fraction is dropped when it is zero. The case from #1026 still reads "2 days", a rate reads "0.05", and a tiny negative value reads "0", not "-0.0". The points themselves are still rounded by whole, as before.

One visible change: the resolved-bug-was-rewarded bylaw now tells a contributor "12.5 days of delay" where it said "13 days" for 300 hours.

The new tests cover a random rate, a negative rate, a third rounded to 0.33, a whole Float printed without a fraction, and a tiny negative Float printed as zero.

Closes #1219

@Thayorns

Copy link
Copy Markdown
Contributor Author

@yegor256 take a look please, happy to clarify anything about this change.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fbe::Award::Bill#line rounds every Float in ${...} to a whole number, so a rate of 0.05 is shown as 0

1 participant