02-05-2014 05:39 PM
Hi,
In my code I should get numeric int numbers and convert them to 1 and 0 , concatenate thm to make an string ( 8 chars) . the problem I have is the empty chars as result of conversion from number to string
so lets say pxiAnaIn=1 dutVdd=2 and dutOut=5 so then the output should be 10110001 but now the output is 10110 1 . could you please let me know how can I fix this problem
thanks
02-05-2014 05:45 PM
Hi Tintin,
Use the Search and Replace function with the search set to " ". The default replace string is "".
Regards,
02-05-2014 05:58 PM
Use %02b and %03b (notice the zeros), this will zero pad your strings so they are the expected width.
02-05-2014 06:07 PM
@tintin_99 wrote:
Hi,
In my code I should get numeric int numbers and convert them to 1 and 0 , concatenate thm to make an string ( 8 chars) . the problem I have is the empty chars as result of conversion from number to string
so lets say pxiAnaIn=1 dutVdd=2 and dutOut=5 so then the output should be 10110001 but now the output is 10110 1 . could you please let me know how can I fix this problem
thanks
You could make your life a little easier and only use 1 format string. Use "%03b%02b%03b" for the format string. You can then expand the format string to allow multiple inputs. You will do the job of 4 functions with just 1.
"%3b" just says to give 3 spaces for the binary number. But any preceding 0s will be turned into spaces. Adding the 0 in there tells the format string to prepend 0s instead of using spaces.