IM
/* scalebin.c - scales binary floating point numbers to
ascii integers between 0 and 255 by
subtracting sub and dividing by div.
sub and div are passed as command line
arguments. User must first determine
correct values for sub and div. */
#include
#include
main(argc, argv)
int argc;
char *argv[];
{
int In;
union {
unsigned long image;
float x;
} both;
float sub, div;
unsigned long in0, in1, in2, in3;
unsigned char c, j = 0;
sscanf(argv[1],"%e",&sub);
sscanf(argv[2],"%e",&div);
while ((In = getchar()) != EOF)
{
in0 = In; in1 = getchar(); in2 = getchar(); in3 = getchar();
in0 <<= 24; in1 <<= 16; in2 <<= 8;
both.image = (in0 | in1 | in2 | in3);
c = floor((both.x - sub)/div);
printf("%u ",c);
if (j++ == 19) {printf("\n"); j = 0;}
}
}