#include <stdio.h>
#include <math.h>

char aa[36];
unsigned int dt;
double p;

main(){
	int i,j,fds,mode=0;
	char d,dd[36];
	fds=fopen("coef.txt","rb");
	for(i=0;i<41;i++){
		j=0; while(1){ d=fgetc(fds); if(d==0x0d) break; dd[j++]=d; } dd[j]=0;
		if(mode>10) printf("%s",dd);
		printf("\n\t.data.w\t");
		j=0; while(1){ d=fgetc(fds); if(d==0x0d) break; aa[j++]=d; } aa[j]=0;
		conv(); if(mode>10) printf("\n%11.8f   ",p);
		calc(); printf("%d,",dt);
		j=0; while(1){ d=fgetc(fds); if(d==0x0d) break; aa[j++]=d; } aa[j]=0;
		conv(); if(mode>10) printf("\n%11.8f   ",p);
		calc(); printf("%d,",dt);
		j=0; while(1){ d=fgetc(fds); if(d==0x0d) break; aa[j++]=d; } aa[j]=0;
		conv(); if(mode>10) printf("\n%11.8f   ",p);
		calc(); printf("%d,",dt);
		j=0; while(1){ d=fgetc(fds); if(d==0x0d) break; aa[j++]=d; } aa[j]=0;
		conv(); if(mode>10) printf("\n%11.8f   ",p);
		calc(); printf("%d,",dt);
		j=0; while(1){ d=fgetc(fds); if(d==0x0d) break; aa[j++]=d; } aa[j]=0;
		conv(); if(mode>10) printf("\n%11.8f   ",p);
		calc(); printf("%d,",dt);
		printf("0,0,0");
	}
	fclose(fds);
}

calc(){
	dt=(int)((p+2.0)*(double)16384);
	if(dt>32767) dt=dt-32768;
	else dt=dt+32768;
}

conv(){
	double r=1.0;
	p=0.0;
	if(aa[6]=='-') r=-1.0;
	p=p+(double)(aa[7]-0x30)*1.0;
	p=p+(double)(aa[9]-0x30)*0.1;
	p=p+(double)(aa[10]-0x30)*0.01;
	p=p+(double)(aa[11]-0x30)*0.001;
	p=p+(double)(aa[12]-0x30)*0.0001;
	p=p+(double)(aa[13]-0x30)*0.00001;
	p=p+(double)(aa[14]-0x30)*0.000001;
	p=p+(double)(aa[15]-0x30)*0.0000001;
	p=p+(double)(aa[16]-0x30)*0.00000001;
	p=p*r;
}

