I have my union setup to read a 32 bit float value which is 32.0800018310 (binary = 100000.0001010001111011).
Now I want to display the contents of the float using the integer array which is 12 bytes (8 bits per byte).
However I get the following output:
Display:
236
81
0
66
Shouldn't:
data_to_send[0]
return the first 8 bits of the float, which is 01111011 (decimal = 123)data_to_send[1]
return the next 8 bits of the float which is 00010100 (decimal = 20)data_to_send[2]
return the next 8 bits of the float which is 100000. (decimal = 32)data_to_send[3]
return the next 8 bits of the float which is 0. (decimal = 0)
Also what happens to the .
in the number? How do you display that?
union
{
uint8_t data_to_send[12];
float float_value;
} union_var;
union_var.float_value = 32.0800018310
//display array
USB.print("Display: ");
USB.printf("%d \n", union_var.data_to_send[0]);
USB.printf("%d \n", union_var.data_to_send[1]);
USB.printf("%d \n", union_var.data_to_send[2]);
USB.printf("%d \n", union_var.data_to_send[3]);