1 2 Previous Next 26 Replies Latest reply on Aug 25, 2017 1:41 AM by user_1377889

    Problem printing float

    user_343349849

       I have been through the knowledgebase and applied suggestions 

         

      Project -> Build Options -> linker -> Command Line -> -u_printf_float

         

      Then tried Linker -> General -> Use newlib nano ... False

         

      Finally tried, asm (".global _scanf_float"); 

         

      None of these seemed to help. I can sprintf decimal values and strings ok but not floating point.

         

      I am using Psoc Creator 3.2 SP1, ARM GCC 4.8.4 compiler, debug build

         

      Here is my code (initially I was trying to print a float var but set an exlicit value to test)

         

      #include "stdlib.h"

         

      char tbuf[50];

         

      sprintf(tbuf,"%f",(float) 1.35);

         

      When I run this my buffer has values like

         

      0x00, 0x2E, 0x80, 0x00, 0x20, 0x11, 0x00 ...

         

      instead of  0x31, 0x2E, 0x33, 0x35

         

      Any help much appreciated

         

      Regards

         

      David

        1 2 Previous Next