I'm excatly doing this with a very simple encoding/decoding without any problem:
Right now I'm putting nx and ny into r and g, and it would be nice if I could put (linear depth)*(sign(nz)) into b and a.
encoding: [depth=0..1] scaled_depth = depth*2048.0; result.x = floor(scaled_depth); result.y = fract(scaled_depth); decoding: result = dot(encoded_depth.xy, vec2(1.0/2048.0,1.0));
A standard depth/stencil buffer have only 24 bits too, so this works for me for lightning, particle depth tests etc.
PS: a fast decoding could be useful too