float-format

Crates.iofloat-format
lib.rsfloat-format
version0.1.3
sourcesrc
created_at2022-06-02 08:07:33.967748
updated_at2022-06-08 16:32:43.217691
descriptionA library for custom floating point number format
homepage
repositoryhttps://github.com/LioQing/float-format
max_upload_size
id598726
size39,984
Lio (LioQing)

documentation

README

Float Format

crates.io downloads docs build size license

This is a crate for customizing the format of floating point numbers. This crate is still work in progress, many features are still to be added.

So far everything is unstable.

use float_format::*;

fn main() {
    // Create with a custom format and parse from a string.
    let float = Float::from_str(
        Format::new_ieee_excess(16, 64),
        "123456.789012345",
    ).unwrap();

    // Format the float with custom precision.
    assert_eq!(format!("{:.8}", float), "123456.78901234");

    // Convert from primitive float types.
    assert_eq!(Float::from(0.2f32).to_f32(), 0.2f32);
    assert_eq!(Float::from(0.2f64).to_f64(), 0.2f64);
}
Commit count: 19

cargo fmt