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

[QUESTION] Use of min_significant_digits with max_significant digits #89

Open
NicholasWMRitchie opened this issue Sep 19, 2022 · 0 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers high priority High priority

Comments

@NicholasWMRitchie
Copy link

NicholasWMRitchie commented Sep 19, 2022

Question

I'd like to always write exactly three significant digits in the fractional part. It would seem that I need to include both min_significant_digits(...) and max_significant_digits(...).

    const FORMAT: u128 = lexical::format::STANDARD;
    OptionsBuilder::new()
        .max_significant_digits(NonZeroUsize::new(3))
        .min_significant_digits(NonZeroUsize::new(3))
        .build()
        .unwrap();
    lexical::to_string_with_options::<_, FORMAT>(val, &options)

However, this always fails with

---- algorithms::stage::test_stage stdout ----
thread 'algorithms::stage::test_stage' panicked at 'assertion failed: bytes.len() >= 20', C:\Users\nicho\.cargo\registry\src\github.com-1ecc6299db9ec823\lexical-write-float-0.8.5\src\algorithm.rs:807:5

What am I doing wrong? min_significant_digits(...) alone seems to work ok.

@NicholasWMRitchie NicholasWMRitchie added the question Further information is requested label Sep 19, 2022
@Alexhuszagh Alexhuszagh added bug Something isn't working high priority High priority good first issue Good for newcomers and removed question Further information is requested labels Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers high priority High priority
Projects
None yet
Development

No branches or pull requests

2 participants