I have this code:
typedef union MyUnion {
int ival;
float fval;
} MyUnion;
MyUnion myUnion;
myUnion.fval = 3.0f;
someFuncCall(myUnion.ival);
What exactly am I doing when I ask for the ival? It is my guess that I am asking for the float to be thought of (encoded as?) an int. I also assume that it has to do with sharing the same space in memory? However, I am definitely uncertain. This is a trick I had to use when sending float data to an FPGA in the Vivado Suite. All data is expected to enter as ints. I'd really appreciate any thorough clarification for what is going on or just pointers to resources. Thanks!