15 unstable releases (6 breaking)

0.7.0 Feb 26, 2025
0.6.0 Nov 23, 2024
0.5.6 May 28, 2024
0.5.5 Nov 16, 2023
0.1.0 Oct 15, 2020

#326 in Internationalization (i18n)

Download history 25083/week @ 2024-11-21 22997/week @ 2024-11-28 30331/week @ 2024-12-05 27390/week @ 2024-12-12 17113/week @ 2024-12-19 6891/week @ 2024-12-26 24128/week @ 2025-01-02 34187/week @ 2025-01-09 31281/week @ 2025-01-16 33721/week @ 2025-01-23 38849/week @ 2025-01-30 42729/week @ 2025-02-06 32797/week @ 2025-02-13 41722/week @ 2025-02-20 41425/week @ 2025-02-27 34295/week @ 2025-03-06

159,386 downloads per month
Used in 70 crates (17 directly)

Unicode-3.0

375KB
7.5K SLoC

fixed_decimal crates.io

fixed_decimal is a utility crate of the ICU4X project.

This crate provides Decimal and UnsignedDecimal, essential APIs for representing numbers in a human-readable format. These types are particularly useful for formatting and plural rule selection, and are optimized for operations on individual digits.

Examples

use fixed_decimal::Decimal;

let mut dec = Decimal::from(250);
dec.multiply_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

~230–700KB
~17K SLoC