13 releases

0.5.6 May 28, 2024
0.5.5 Nov 16, 2023
0.5.4 Sep 22, 2023
0.5.3 Apr 13, 2023
0.1.0 Oct 15, 2020

#147 in Internationalization (i18n)

Download history 5375/week @ 2024-03-25 4290/week @ 2024-04-01 5994/week @ 2024-04-08 3976/week @ 2024-04-15 5001/week @ 2024-04-22 3822/week @ 2024-04-29 4286/week @ 2024-05-06 4037/week @ 2024-05-13 4070/week @ 2024-05-20 4320/week @ 2024-05-27 4532/week @ 2024-06-03 3977/week @ 2024-06-10 3752/week @ 2024-06-17 3961/week @ 2024-06-24 3913/week @ 2024-07-01 4496/week @ 2024-07-08

16,295 downloads per month
Used in 49 crates (13 directly)

Unicode-3.0

290KB
4.5K SLoC

fixed_decimal crates.io

fixed_decimal is a utility crate of the ICU4X project.

It includes FixedDecimal, a core API for representing numbers in a human-readable form appropriate for formatting and plural rule selection. It is optimized for operations involving the individual digits of a number.

Examples

use fixed_decimal::FixedDecimal;

let dec = FixedDecimal::from(250).multiplied_pow10(-2);
assert_eq!("2.50", format!("{}", dec));

#[derive(Debug, PartialEq)]
struct MagnitudeAndDigit(i16, u8);

let digits: Vec<MagnitudeAndDigit> = dec
    .magnitude_range()
    .map(|m| MagnitudeAndDigit(m, dec.digit_at(m)))
    .collect();

assert_eq!(
    vec![
        MagnitudeAndDigit(-2, 0),
        MagnitudeAndDigit(-1, 5),
        MagnitudeAndDigit(0, 2)
    ],
    digits
);

More Information

For more information on development, authorship, contributing etc. please visit ICU4X home page.

Dependencies

~0.4–0.9MB
~20K SLoC