static float ReadFloat(const void *data) { // Read the 4 big endian bytes from the buffer uint32_t value = ReadUnalignedBE32((const uint32_t *)data); // Convert to little endian value = ToLE32(value); // Extract the components uint32_t exponent = (value & 0xFF000000) >> 24; bool sign = (value & 0x00800000) != 0; uint32_t mantisse = (value & 0x007FFFFF); // Adjust exponent offset exponent -= sign ? 1 : 2; // Assemble the result uint32_t result = mantisse | (exponent << 23); if (sign) result = result | 0x80000000; // Convert little endian to system result = FromLE32(result); // Return result as float return *((float *)&result); }
void IOBuffer::storeFloatLE(float data) { ensureSize(4); data = ToLE32(data); memcpy(buffer+published, &data, 4); published += 4; }
void IOBuffer::storeUI32LE(rx_uint32 data) { ensureSize(4); data = ToLE32(data); memcpy(buffer+published, &data, 4); published += 4; }