bigdecimal-rs icon indicating copy to clipboard operation
bigdecimal-rs copied to clipboard

[Possible Bug] - Display panics for large numbers

Open DanielBauman88 opened this issue 1 year ago • 3 comments

Is this intentional? I think it'd be an improvement to avoid panics in display, and simply use a different display format for numbers that can't be displayed with the standard implementation.

EG: the following test will panic

    #[test]
    fn test_big_scale() {
        let min: i64 = i64::MIN;
        let str = &format!("1E{min}");
        BigDecimal::from_str(str).unwrap().to_string();
    }

Will panic with "attempt to subtract with overflow"

Same for example for

    #[test]
    fn test_small_scale() {
        let max: i64 = i64::MAX;
        let str = &format!("1E{}", max);
        BigDecimal::from_str(str).unwrap().to_string();
    }

DanielBauman88 avatar Jul 19 '23 23:07 DanielBauman88