Casting between short int arrays and float

So, I'm working on a project where I am loading configurations from nonvolatile memory (NVM). Because of this, I'm including a CRC along with the rest of the data to ensure that the data was not corrupted somehow and restore the data if necessary. However, I am running into a block with processing the data. While I know how to write or load the block of data from the NVM, the issue I run into is how to process the data once I've loaded it. For those that don't know a Float is a 4 byte number, and I'm organizing the data I save into 32 long single byte arrays with the data encoded into it and pulling the data out and dumping the data into this array.

When I write it, I convert the float into an 4 Byte array, then copy the array into memory:

	uint8_t data_buff[30];
	float temp_f = 0.0;
	uint8_t * temp_f_array;

	temp_f = MAGIC_FLOAT_NUMBER; //4 Bytes
	temp_f_array = (uint8_t*) &temp_f;
	memcpy(&data_buff[0], &temp_f_array[0], 4);
[\code] (I believe this code works, testing is somewhat hard without)

Now the problem I'm having is figuring out what I need to do to point the float temp_f at the same place as temp_f_array so I can consider it a float value.
I've tried:
&temp_f = (float *) temp_f_array;

But this is not legal code: (lvalue required as left operand of assignment, IE I cannot use '&' on the left side)
How can I perform this operation?


Using a union would be the best way, but try this:

temp_f = *((float *)temp_f_array);

Thanks! But, I'm going with a union. I'm not sure my reverse process is doing what I think it should be.

I would have thought a struct to hold the individual fields and take the address and size to pass the underlying bytes to the functions that add the CRC and read/write to persistent storage. If you want you could use a union with a byte array with the same number of elements as the size of the struct, but that hardly seems to save you anything compared to & and sizeof() operators. Once you've defined the struct, presumably you'd provide functions to read and write that struct to/from storage.