Skip to content

[mbed-os-6.6.0] minimal-printf incorrect output #14069

@caoddx

Description

@caoddx

Description of defect

Floating point number is not printed correctly.

test code

  printf("123.456: %f\n", 123.456);
  printf("0.456: %f\n", 0.456);
  printf("-0.456: %f\n", -0.456);
  printf("123.0: %f\n", 123.0);

  // output:
  // 123.456: 123.000123
  // 0.456: 0.000000
  // -0.456: -0.000000
  // 123.0: 123.000123

mbed_app.json

{
    "target_overrides": {
        "*": {
            "target.printf_lib": "minimal-printf",
            "platform.minimal-printf-enable-floating-point": true,
            "platform.minimal-printf-set-floating-point-max-decimals": 6,
            "platform.minimal-printf-enable-64-bit": true
        }
    }
}

It seems that the variable precision in the file mbed_printf_implementation.c is not used.

Target(s) affected by this defect ?

should be all

Toolchain(s) (name and version) displaying this defect ?

GCC_ARM

What version of Mbed-os are you using (tag or sha) ?

mbed-os-6.6.0

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

mbed-cli

How is this defect reproduced ?

use the above test code and mbed_app.json

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions