/*
	exphist.c

	processes '.val' files to find occurances of 'float' exponents

	R. Ambroziak USGS/OMG

*/
#include <stdio.h>
#include <string.h>
#include <math.h>
#include "font.h"
#include "nomouse.h"

#define MSK_EXP_IEEE  0x7f800000
#define MSK_SIGN_IEEE 0x80000000

unsigned char Buffer[1024];
long Hist[256];

main(argc,argv)

int argc;
char *argv[];
{
	int i,j,k;
	int numbyt,numfile=0;
	char name[100];
	FILE *fp;
	long num=0,*data=(long *)Buffer,expon,sign;


	numfile=get_file_name("*.val",name,numfile);
	fp=fopen(name,"rb");
	if(!fp)
	{
		printf("Could not open '%s'\n",name);
		exit(0);
	}
	while((numbyt=fread((char *)Buffer,sizeof(char),1024,fp))>0)
	{
		num+=numbyt/4;
		for(i=0;i<numbyt/4;i++)
		{
			expon=(data[i]&MSK_EXP_IEEE)>>23;
			j=expon;
			Hist[j]+=1;
		}
	}
	printf("There are %ld numbers in file.\n",num);

	for(j=0;j<256;j++)
		if(Hist[j]>0)
			printf("%6d%10ld",j,Hist[j]);
}




                                                     