Skip to content
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 #216 #218

Merged
merged 3 commits into from
Jun 25, 2022
Merged

Fix #216 #218

merged 3 commits into from
Jun 25, 2022

Conversation

Pat-Lafon
Copy link
Contributor

This pr attempts to specify the output value of printing a float. A first pass of this is added to the documentation of the floating point extension. brili and brilirs have been modified to be compliant. The tests/benchmarks which output floats have also been updated.

@sampsyo
Copy link
Owner

sampsyo commented Jun 25, 2022

Awesome; looks perfect!! I just tweaked the docs a bit for precision (and moved the text to a new section just about printing).

I was going to suggest that we not include trailing zeroes, because C printf and Python string formatting make this easy with the g specifier:

>>> '{:.17f}'.format(.5)
'0.50000000000000000'
>>> '{:.17g}'.format(.5)
'0.5'

…but it looks like Rust does not make this easy to do (see rust-lang/rust#29472) so that's probably too much trouble.

@sampsyo sampsyo merged commit 463ab26 into sampsyo:main Jun 25, 2022
sampsyo added a commit that referenced this pull request Jun 25, 2022
Makes Brilift conform to the new spec in #218 for printing all floats
with 17 decimal digits of precision. Now all the float tests pass.
@Pat-Lafon
Copy link
Contributor Author

Seems like this was somewhat discussed more recently in rust-lang/rfcs#2729 but they didn't go so far as to fully implement g behavior. If this is something you would prefer, it naively seems like a relatively straight forward change for brilirs.

If it's just a matter of trailing zeros, then https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=3ea18aef3548196ad33d8c6aa386364f seems reasonable.

If there is other behavior to be aware of, then there is atleast one crate that gives the desired behavior https://crates.io/crates/gpoint .

@Pat-Lafon Pat-Lafon deleted the floats branch June 25, 2022 20:41
@sampsyo
Copy link
Owner

sampsyo commented Jun 26, 2022

Ah, good digging!! Honestly I think it's totally cool to use this zero-having output… at the very least it's simple to specify. We can always revisit if someone eventually gets super annoyed staring at 1.00000000000000000 instead of 1.0. 😃

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.

2 participants