/* stof12--float to short for 12-bit DAC
 * stof12 < infile > outfile
 */
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
#define  DAC12 2047 /* 2^12 / 2 - 1 */

main()
{
    short x;
    float y;
    setmode(fileno(stdin), O_BINARY);
    setmode(fileno(stdout), O_BINARY);

    while (fread((char *)&x, sizeof(short), 1, stdin))
    {     y = x / DAC12;
          fwrite((char *)&y, sizeof(float), 1, stdout);
    }
}