9 unstable releases (4 breaking)

0.5.2 Jan 26, 2023
0.5.1 Oct 20, 2022
0.5.0 Sep 27, 2022
0.3.0 May 10, 2022
0.1.0 Oct 15, 2020

#23 in #cldr

Download history 1986/week @ 2022-11-28 1430/week @ 2022-12-05 1349/week @ 2022-12-12 1215/week @ 2022-12-19 307/week @ 2022-12-26 590/week @ 2023-01-02 1428/week @ 2023-01-09 1194/week @ 2023-01-16 1751/week @ 2023-01-23 1634/week @ 2023-01-30 2659/week @ 2023-02-06 1841/week @ 2023-02-13 2051/week @ 2023-02-20 1957/week @ 2023-02-27 1405/week @ 2023-03-06 1934/week @ 2023-03-13

7,431 downloads per month
Used in 18 crates (6 directly)

Unicode-DFS-2016

170KB
3K 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.7–1.1MB
~28K SLoC