11 Replies Latest reply on Mar 1, 2015 1:11 AM by user_342122993

    Convert string to number, e.g. float with error handling

    user_342122993

       While receiving UART commands, I need to convert strings to numerical values. For example, string "1.23" would produce float number 1.23 using function 'atof()':

         

      V=atof('1.23…');

         

       

         

      Unfortunately, in the case of a typo this function will return a valid number also ("0"), which will be passed to the program. For example:

         

       

         

      atof('1.$23…')=0,    ($ is a typo)

         

       

         

      Is there any built-in function to check for valid input number?

         

      regards,

         

      odissey1