There are some standard 16-bit floating point values, but they are pretty limited in useability - graphics processors use them somtimes to store "floating point pixels".
What range are your numbers? Would it be suitable to store them in a 12-bit signed integer and 4-bit fraction part?
The following does that. Note that you loose quite a bit of precision this way, but you can't have both compact format and a lot of precision.
Code:
#include <stdio.h>
#include <math.h>
short ftofix16(float num) {
short i, f;
if (fabs(num) > 2047.999f) {
printf("Error: number out of range (num=%f)\n", num);
}
i = (short)num;
f = (short)(fabs(num * 16)) & 15;
return (i << 4) | f;
}
float fix16tof(int n)
{
float s = 1.0f;
if (n < 0) {
s = -1.0f;
n = -n;
}
return s * ((float)(n >> 4) + ((n & 15) / 16.0f));
}
int main(int argc, char **argv) {
float f, g, h;
short a, b, c;
for(;;) {
scanf("%f %f %f", &f, &g, &h);
a = ftofix16(f);
b = ftofix16(g);
c = ftofix16(h);
printf("%04x, %04x, %04x\n", a, b, c);
printf("%f, %f, %f\n", fix16tof(a), fix16tof(b), fix16tof(c));
}
return 0;
}