There are many ways to approximate real numbers. There are floating point representations where some bits represent an exponent and some other bits represent a coefficient, there are fixed point representations where some bits represent the whole number part and some bits represent the factional part, there are arbitrary finite precision representations where some number of 'digits' in some base are stored, etc., and for every general class of representation there is an infinite variety of details which would matter when converting that representation into floats.
Your question does not specify what representation the byte array contains. Specifying that the array is Ipp8u does not come close to providing the necessary information.
What you probably mean is that the byte array contains a byte representation of the machine's native representation of floats (which is probably IEEE-754), differing at most in endianess.
You can simply do a memcpy of data from the char array into an array of floats:
char c[10 * sizeof(float)] = {...};
float f[10];
std::memcpy(f, c, 10 * sizeof(float)); // or you can search for an implementation of bit_cast
One thing not to do is to simply cast the char array: float *f = reinterpret_cast<float*>(c); This cast probably has undefined behavior because float probably has stricter alignment requirements than char.
If the endianess differs then you go through the byte array first and reorder the bytes, something like this:
// assuming sizeof(float) == sizeof(uint32_t)
for (int i; i<sizeof c; i+=sizeof(float)) {
uint32_t i;
std::memcpy(&i, c + i, sizeof(uint32_t));
ntoh(i); // swaps bytes from Network TO Host order.
std::memcpy(c + i, &i, sizeof(uint32_t));
}
floats? Or something else? - Matteo Italia