Debian Codegraph @

debian/rust-vendor/fixed_decimal/README.md

raw
1 # fixed_decimal [![crates.io](https://img.shields.io/crates/v/fixed_decimal)](https://crates.io/crates/fixed_decimal)
2
3 <!-- cargo-rdme start -->
4
5 `fixed_decimal` is a utility crate of the [`ICU4X`] project.
6
7 This crate provides [`Decimal`] and [`UnsignedDecimal`], essential APIs for representing numbers in a human-readable format.
8 These types are particularly useful for formatting and plural rule selection, and are optimized for operations on individual digits.
9
10 ## Examples
11
12 ```rust
13 use fixed_decimal::Decimal;
14
15 let mut dec = Decimal::from(250);
16 dec.multiply_pow10(-2);
17 assert_eq!("2.50", format!("{}", dec));
18
19 #[derive(Debug, PartialEq)]
20 struct MagnitudeAndDigit(i16, u8);
21
22 let digits: Vec<MagnitudeAndDigit> = dec
23 .magnitude_range()
24 .map(|m| MagnitudeAndDigit(m, dec.digit_at(m)))
25 .collect();
26
27 assert_eq!(
28 vec![
29 MagnitudeAndDigit(-2, 0),
30 MagnitudeAndDigit(-1, 5),
31 MagnitudeAndDigit(0, 2)
32 ],
33 digits
34 );
35 ```
36
37 [`ICU4X`]: ../icu/index.html
38
39 <!-- cargo-rdme end -->
40
41 ## More Information
42
43 For more information on development, authorship, contributing etc. please visit [`ICU4X home page`](https://github.com/unicode-org/icu4x).