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

Panic on round call #90

Closed
mashedcode opened this issue Aug 5, 2022 · 4 comments
Closed

Panic on round call #90

mashedcode opened this issue Aug 5, 2022 · 4 comments

Comments

@mashedcode
Copy link

use bigdecimal::BigDecimal;
use std::str::FromStr;

fn main() {
    let decimal = BigDecimal::from_str("0.1165085714285714285714285714285714285714").unwrap();
    decimal.round(0); // called `Option::unwrap()` on a `None` value bigdecimal-rs/src/lib.rs:594:43
}

This panics. Complied against master.

@Niedzwiedzw
Copy link

same

@yamelsenih
Copy link

I think that a simple solution can be trunc the number if the digits is to long that i128 support

Best regards.

@yamelsenih
Copy link

Other solution is handle it as String instead

@akubera
Copy link
Owner

akubera commented Jul 5, 2023

This has been fixed, and the example (for multiple rounding points) has been added to the unit tests.

@akubera akubera closed this as completed Jul 5, 2023
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

No branches or pull requests

4 participants