12 releases

0.5.5 Nov 16, 2023
0.5.3 Apr 13, 2023
0.5.2 Jan 26, 2023
0.5.1 Oct 20, 2022
0.1.0 Oct 15, 2020

#126 in Internationalization (i18n)

Download history 4057/week @ 2023-12-18 1780/week @ 2023-12-25 3324/week @ 2024-01-01 2999/week @ 2024-01-08 4275/week @ 2024-01-15 3577/week @ 2024-01-22 6223/week @ 2024-01-29 5344/week @ 2024-02-05 5557/week @ 2024-02-12 4120/week @ 2024-02-19 5339/week @ 2024-02-26 4928/week @ 2024-03-04 5503/week @ 2024-03-11 4718/week @ 2024-03-18 5384/week @ 2024-03-25 4014/week @ 2024-04-01

19,956 downloads per month
Used in 44 crates (12 directly)

Custom license

270KB
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.8MB
~20K SLoC