4 Replies Latest reply on Mar 7, 2016 10:00 AM by MichaelF_56

    Calculation and printing of a floating point number BCM20737s

      Hello,

       

      I am having some trouble with floating point numbers. I am using the lastest SDK.

       

      I have a simply calculation:

       

      int Data[]={0x1834};      //6196 in decimal

      float factor=0.00698;

      float result=0;

       

      result=Data[0]*0.00698;    //expected result would be 43.24808

       

      printf("Result: %.2f",result);  //print to two decimal places, 43.24

       

      Every time I do this I get a round number to a whole number.

      What is the correct way to print to two decimal places on this SDK?

       

      Do I need to include some sort of header file to allow me to calculate floating point calculations?

       

      Any examples would be great.

       

      Thanks,

      Luke.