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

Implement LowerExp and UpperExp for integers #39479

Closed
clarfonthey opened this issue Feb 3, 2017 · 5 comments
Closed

Implement LowerExp and UpperExp for integers #39479

clarfonthey opened this issue Feb 3, 2017 · 5 comments
Labels
C-feature-accepted Category: A feature request that has been accepted pending implementation. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@clarfonthey
Copy link
Contributor

clarfonthey commented Feb 3, 2017

I'd be willing to work on this at some point, but I figured that I'd offer this as a feature request in case someone else is interested.

It's very useful to be able to print large integers in scientific notation to get a glance at what order of magnitude they are. For example, seeing 1e10 is much easier to comprehend than 10000000000.

@phungleson
Copy link
Contributor

Thanks @clarcharr, looks interesting and simple enough for me.

I can look into this.

@phungleson
Copy link
Contributor

@clarcharr seems like the implementation for f32 and f64 is around this function

fn float_to_exponential_common<T>(fmt: &mut Formatter, num: &T, upper: bool) -> Result

Do you think we can just reuse it?

@hanna-kruppe
Copy link
Contributor

hanna-kruppe commented Feb 6, 2017

That code is strongly tied to floats. I don't believe it can be reused for (64- and 128-bit) integers at all, but even if, it would probably be much more painful than just writing a clean-room implementation tailored to integers.

@Mark-Simulacrum Mark-Simulacrum added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label May 20, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-feature-request Category: A feature request, i.e: not implemented / a PR. label Jul 27, 2017
@dtolnay dtolnay added C-feature-accepted Category: A feature request that has been accepted pending implementation. and removed C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Nov 18, 2017
@dtolnay
Copy link
Member

dtolnay commented Nov 18, 2017

I agree that a separate implementation for integers would be easier than trying to use the float one. I would love a PR to add these impls!

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Feb 15, 2020
implement LowerExp and UpperExp for integers

Addresses rust-lang#39479

This implementation is heavily based on the preexisting `macro_rules! impl_Display` in the same file. I don't like the liberal use of unsafe in that macro and would like to modify it so `unsafe` is only present where necessary. What is Rust's policy on doing such modifications?

Also, I couldn't figure out where to put tests, can I have some help with that?
@maxbla
Copy link
Contributor

maxbla commented Mar 12, 2020

I fixed this with #66721, but this issue wasn't automatically closed

@dtolnay dtolnay closed this as completed Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-accepted Category: A feature request that has been accepted pending implementation. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants