01-18-2017 02:41 AM
Hello,
I have a variable float type (example float a = 5.02) and I want to save the value into unsigned char.
I tryed to cast the value but it dosn't work 😕
unsigned char a; float b = 5.02; a = (char)b;
Regards,
Solved! Go to Solution.
01-18-2017 04:27 AM
I have found a solution.
We need to convert the float to int then to unsigned char by simple cast.
Regards,
01-29-2017 09:04 AM
try this:
char stringvariable [LINELEN+1];
float floatwariable;
sprintf(string,"%f",floatvariable);
or use CVI's own conversion function
"
The formatting functions format and combine multiple source items into a single target item. The only difference in the workings of the three functions is the location of the target data. For Fmt, the target is a data item in memory that you pass to the function by reference. You must pass the target parameter for Fmt by reference. For FmtFile, the target is a file whose handle you pass as the first argument. For FmtOut, the target is the Standard Output, which is typically the display. FmtOut omits the target argument present in the other two functions. Except for these differences, the following descriptions apply to all the formatting functions.
The formatting functions have a formatString parameter that contains the information needed to transform the source arguments to the target argument. Format strings for all the formatting functions are of the following form:
"target_spec < source_specs_and_literals"