I have an array of 32-bit long integers. Some of the elements will afterwards be used as 32-bit floats. I would like to supply an initializer list to initialize these floating point values correctly. For example, if the first two elements are used as integers, and the third as float, and I wish to initialize the third element to be equal to 100.0, I am forced to do this:
long a[3]={10,20,0x42c80000};
This works fine, but is not very expressive.
If I do this:
long a[3]={10,20,100.0};
The compiler will convert the floating point literal to 0x64.
I do not have a C++11 compiler, so using a union will not work.
Any ideas?