This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF_LOG print double precision float number

I am on SDK15.3, NRF52840, armgcc, makefile, console

I need to print a double float number in format of "x.xxxxE-xx". I already know that NRF_LOG can only print float with MARKER, so I use sprintf to format the number into a string buffer first, and then I use NRF_LOG to print that string using "%s" format specifier.

    char abuf[40];
    memset(abuf, 0, sizeof(abuf));

    uint8_t len = sprintf(abuf, "%.5E", 3000.8766);
 
    NRF_LOG_DEBUG("[KF] updated K gain: %s, %d\n", abuf, len);
    

However I only get white spaces or unprintable character.

Anyway I can do this properly?

thank you.

/Roland

Parents Reply Children
Related