6 releases (3 breaking)

new 0.4.0 Aug 4, 2022
0.3.0 May 10, 2022
0.2.2 Jan 31, 2022
0.2.1 Jul 21, 2021
0.1.0 Oct 15, 2020

#16 in #cldr

Download history 97/week @ 2022-04-21 182/week @ 2022-04-28 186/week @ 2022-05-05 253/week @ 2022-05-12 1195/week @ 2022-05-19 582/week @ 2022-05-26 608/week @ 2022-06-02 1076/week @ 2022-06-09 2390/week @ 2022-06-16 2053/week @ 2022-06-23 2694/week @ 2022-06-30 2518/week @ 2022-07-07 2642/week @ 2022-07-14 2356/week @ 2022-07-21 4618/week @ 2022-07-28 2862/week @ 2022-08-04

12,886 downloads per month
Used in 12 crates (4 directly)

Unicode-DFS-2016

155KB
2.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

~315–760KB
~17K SLoC