Listing 1—You can use  the JMATH package to generate a sine, cosine, and square root table.

//Test the N ! function from 0! to 100! and see how big the
  PIC18F452 C stack is
	
//for (i=0; i<100; i++)
for (i=0; i<12; i++)
{
		y = Factorial((double) i);
		dec(i);
		printf("! = ");
//Convert the value in  x and y from float to ascii for display
//on the monitor, LED, or LCD
		DoubleToAscii(y, ay);
		puts(ay);
		printf("\r\n");
	//pause(1000);
	}

//Generate table of sines from 0..360 degrees and write the
//results to a log file (sin.log)

printf("Generate a Sine table from 0 to 360 degrees  ... \r\n");
	
for (i=0; i<360; i++)   
{
		x =  (double)i*ConvertToRadians;
		y = sin(x);
			
//Send result to Serial Port
 		
#ifdef PIC18C452
		printf("  i = ");
		dec(i);
		printf(" x = ");
		
//Convert the value in  x and y from float to ascii for display
//on the monitor, LED, or LCD

		DoubleToAscii(x, ax);
		string(ax);
		printf(" sin(x) = ");
		DoubleToAscii(y, ay);
		string(ay);
		printf("\r\n");	
		//pause(500);	//Wait to allow viewing of the results

#else
		printf("  i = %d,  x = %15.8le, sin = %15.8le  \n", i, x, y);

		//fprintf(f1,"  i = %d,  x = %15.8le, sin = %15.8le  \n", i, 			x, y);
		fprintf(f1,"%15.8le \n", y);
#endif
 
	}