#rational-numbers

big-rational-str

Format and parse BigRationals to/from decimal numbers

4 releases

0.1.6 Mar 8, 2023
0.1.5 Mar 26, 2022
0.1.4 Feb 8, 2022
0.1.3 Oct 18, 2020

#244 in Science

Download history 18/week @ 2024-07-20 29/week @ 2024-07-27 23/week @ 2024-08-03 48/week @ 2024-08-10 23/week @ 2024-08-17 25/week @ 2024-08-24 100/week @ 2024-08-31 77/week @ 2024-09-07 61/week @ 2024-09-14 80/week @ 2024-09-21 47/week @ 2024-09-28 39/week @ 2024-10-05 58/week @ 2024-10-12 3/week @ 2024-10-19 7/week @ 2024-11-02

69 downloads per month
Used in rpn-cli

Custom license

8KB
156 lines

big-rational-str

Crate for formatting and parsing BigRationals (of the popular 'num' crate) in decimal form.

Converts fractions to decimal strings and vice versa

BigRational String
1/3 "0.(3)"
-93/52 "-1.78(846153)"
30/4 "7.5"
550/-1 "-550"

Usage

use big_rational_str::*;

fn main() {
    let big_rational = str_to_big_rational("3.(3)").unwrap();
    println!("{}", big_rational_to_string(big_rational));
    
    let big_rational2 = BigRational::from_dec_str("3.(3)").unwrap();
    println!("{}", big_rational2.to_dec_string());
}

Dependencies

~2.7–4.5MB
~80K SLoC