2 Replies Latest reply on May 27, 2017 10:11 PM by SumatPurewal

    PSOC5 division

    SumatPurewal

      I noticed through the following that division by a number much larger than a 1000 doesn't work well unless it is broken into steps. Why is this the case? I assumed that this is something that would be done automatically..

         

      pulselen = (Ch1Period - Channel_1_Count)/1000000;

         

      sprintf(StringToPrint,"pulselen is %lf s \r\n",pulselen);   ///DOESNT WORK-prints 0.000000
      UART_1_PutString(StringToPrint);

         

      pulselen = (Ch1Period - Channel_1_Count)/100;
      pulselen = pulselen/100;
      pulselen = pulselen/100;

         

      sprintf(StringToPrint,"pulselen is %lf s \r\n",pulselen);   ///WORKS
      UART_1_PutString(StringToPrint);