So I've looked around, and there is a lot of info to be found on this subject, but it is only for encoding floats in the range [0, 1], and I want to encode floats of arbitrary magnitude. Can you tell me if my method is sound?

On the CPU:

glm::ivec4 FloatToRGBA(float input) { int exponent; float significand = frexp(input, &exponent); int sig_int = glm::round(significand * 16777215.0f); glm::vec4 output; output.x = exponent + 128; output.y = sig_int & 0x000000FF; output.z = (sig_int & 0x0000FF00) >> 8; output.w = (sig_int & 0x00FF0000) >> 16; return output; }

On the GPU:

float RGBAtoFloat(float4 input) { float significand = dot(input.yzw, float3(16711680.0f, 65280.0f, 255.0f)) / 16777215.0f; return ldexp(significand, input.x * 255.0f - 128.0f); }

**Edited by Chris_F, 17 January 2013 - 04:13 PM.**