#engineering #notation #f64 #formatting #string #traits #containing

eng_fmt

Zero-depedency rate containing trait providing engineering notation formatting for f64

3 releases

0.1.2 Sep 18, 2023
0.1.1 Sep 18, 2023
0.1.0 Sep 15, 2023

#137 in Value formatting

Download history 98/week @ 2024-03-13 219/week @ 2024-03-20 466/week @ 2024-03-27 221/week @ 2024-04-03 68/week @ 2024-04-10 88/week @ 2024-04-17 204/week @ 2024-04-24 138/week @ 2024-05-01 161/week @ 2024-05-08 257/week @ 2024-05-15 220/week @ 2024-05-22 491/week @ 2024-05-29 510/week @ 2024-06-05 734/week @ 2024-06-12 146/week @ 2024-06-19 117/week @ 2024-06-26

1,646 downloads per month
Used in 2 crates

BSD-3-Clause

10KB
242 lines

eng_fmt

This is a Rust crate that formats f64 as a String in engineering notation.

Change Log

  • 0.1.2: Tweaked this readme and fixed a bad link.
  • 0.1.1: Provided much better examples in documentation.

lib.rs:

Module containing trait to format f64 in engineering notation.

Examples

use eng_fmt::FormatEng;
let x: f64 = 0.010;
let expected = "10.0e-3".to_string();
assert_eq!(x.format_eng(None), expected);
use eng_fmt::FormatEng;
let x = std::f64::consts::PI;
let expected = "3.142".to_string();
assert_eq!(x.format_eng(Some(4)), expected);
use eng_fmt::FormatEng;
let x = 6.022e-23;
let expected = "60.2e-24".to_string();
assert_eq!(x.format_eng(None), expected);

No runtime deps