Skip to content

Round a Float in the bylaw text to two decimals - #1308

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

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

Conversation

@Thayorns

Copy link
Copy Markdown
Contributor

Since #992 a let in a bylaw can hold a computed value, and Fbe::Award::Bylaw#line printed it with plain interpolation. So a bylaw could say "award 0.30000000000000004 points" or "0.3333333333333333", as #1220 shows.

Now a Float in ${...} of a bylaw line is rounded to two decimals, and the fraction is dropped when it is zero, by a private short in Bylaw. That is the same rule #1219 proposes for the text of a bill, so both sides of one policy print a value the same way. Integers and Strings are printed as before.

The new tests cover 0.1 × 3, a third, a random negative rate, a whole Float and a tiny negative Float.

Closes #1220

@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::Bylaw#line prints an unrounded Float, so a bylaw says "award **0.30000000000000004** points"

1 participant