3 Replies Latest reply on Dec 16, 2017 9:52 AM by vcerchez_2419971

    Does anybody knows if sprintf still works on float numbers to print on LCD?

    vcerchez_2419971

      I know there were discussions in the past related to sprintf, yet I cannot accomplish a simple task: to print on LCD a float using sprintf.

      I use CY8CKIT-059 Kit and a Character LCD. The LCD displays everything but it fails to display a float number. For clarity I attach the bundle.

      Is there something not right with stdio, or the sprintf... I ran out of ideas and the code looks so simple:

      #include <project.h>

      #include <stdio.h>

      int main() 

      {

        char str[16];

       

        float Numb3r = 3.1416;

        LCD_Start();

        LCD_Position(0,0);

        sprintf(str, "Pi = %1.4f...", Numb3r ); 

        LCD_PrintString(str);

       

      }

      Is there a known bug, or anyone knows an workaround...

       

      Thanks.