Skip to content

uFmt_f32 doesn't handle negative decimal values. #5

@abishekatp

Description

@abishekatp

Hi, This library is very useful and thank you for that. I have faced an issue printing negative f32 values. the following code prints out 0.00 instead of -0.22.

let y = ufmt_float::uFmt_f32::Two(-0.22);
ufmt::uwriteln!(&mut serial,  "y: {}\r", y ).void_unwrap();

Adhoc solution:

let mut y = -0.22;
let mut y_sym = "";
if y < 0.0 { 
   y_sym = "-"; 
   y = y * -1.0;
}
let y = ufmt_float::uFmt_f32::Two(y);
ufmt::uwriteln!(&mut serial, "y: {}{}\r", y_sym, y ).void_unwrap();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions