How to print floating point numbers in a flash drive/ SD card using FAT File System?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to print floating point numbers in a flash drive/ SD card using FAT File System?

1,616 Views
Amit_Kumar1
Senior Contributor II

Hello all

I was going through the FATFS documentation and I came to know that we cannot print the floating point numbers using fprintf command in FATFS. But I wanted to print the floating values So How can I do that??

pastedImage_0.png

Thanks and Regards

Amit Kumar

Tags (3)
0 Kudos
Reply
1 Reply

962 Views
egoodii
Senior Contributor III

For a 'limited range and scope' of 'floating point print' you can 'fake it' with integer operations.  Say you have an integer, say in this case one that represents milli-celsius (or a float, with slower math) so we always print exactly three digits after the decimal point:

     if( (temp < 0) && ((temp/1000) == 0) )

          printf("-");        //For our integer pseudo-float print, a zero-whole won't print '-' for us...

     printf(" %i.%03i degrees C\n",temp/1000,abs(temp)%1000);

Personally, I quickly gave up on this trick and opted to 'disable' the 'reduced function' printf from the example code sets and included the full-function compiler version, connecting the 'write' function to my console output.

0 Kudos
Reply