#numbers #precision #float #output #ufmt #level #f32

no-std ufmt_float

A rough implementation of a writer for f32 and f64 for ufmt

2 unstable releases

0.2.0 Sep 8, 2022
0.1.0 Jan 2, 2020

#487 in Embedded development

Download history 7/week @ 2023-12-04 1/week @ 2023-12-11 40/week @ 2023-12-18 20/week @ 2024-01-29 8/week @ 2024-02-12 16/week @ 2024-02-19 46/week @ 2024-02-26 13/week @ 2024-03-04 14/week @ 2024-03-11 14/week @ 2024-03-18

89 downloads per month
Used in 3 crates (via simmer)

MIT license

11KB
135 lines

A writer for f32 and f64 for ufmt

There are six levels of precision based on the number of places after the decimal point. The accuracy depends a lot on the number of significant figures and the decimal selected. Use the lowest precision possible for the best results.

How to use:

  • Build the uFmt_fx enum with the variant the level of precision required
  • Send that variable to the ufmt macro
  • The macro will then output the text representation of the float.
use ufmt::{uwriteln};    
use ufmt_float::uFmt_f32;
let pi = 3.14159234;
let mut s = String::new();
let pi_write = uFmt_f32::Zero(pi);
uwriteln!(&mut s, "{}",pi_write).unwrap();

Current accuary is about 4-5 significant figures depending on the value.

The only relevant feature is maths. If this is set, the library will use the micromaths crate to perform the transformation on the f32 struct. If not selected it will use a method that works in theory but may intoduce errors.

Please add an issue or PR if you have a suggestion on how to increase this.

There is no rounding on the last digit nor is the seperator selectable at the moment

Dependencies

~1.5MB
~36K SLoC