Commit 097c0df4 authored by kuhnm's avatar kuhnm

basicmath ohne prints

parent 691ed21c
#include "snipmath.h"
#include <math.h>
#include <stdio.h>
/* The printf's may be removed to isolate just the math calculations */
......@@ -18,60 +19,60 @@ int main(void)
printf("********* CUBIC FUNCTIONS ***********\n");
/* should get 3 solutions: 2, 6 & 2.5 */
SolveCubic(a1, b1, c1, d1, &solutions, x);
printf("Solutions:");
for(i=0;i<solutions;i++)
printf(" %f",x[i]);
printf("\n");
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
a1 = 1.0; b1 = -4.5; c1 = 17.0; d1 = -30.0;
/* should get 1 solution: 2.5 */
SolveCubic(a1, b1, c1, d1, &solutions, x);
printf("Solutions:");
for(i=0;i<solutions;i++)
printf(" %f",x[i]);
printf("\n");
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
a1 = 1.0; b1 = -3.5; c1 = 22.0; d1 = -31.0;
SolveCubic(a1, b1, c1, d1, &solutions, x);
printf("Solutions:");
for(i=0;i<solutions;i++)
printf(" %f",x[i]);
printf("\n");
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
a1 = 1.0; b1 = -13.7; c1 = 1.0; d1 = -35.0;
SolveCubic(a1, b1, c1, d1, &solutions, x);
printf("Solutions:");
for(i=0;i<solutions;i++)
printf(" %f",x[i]);
printf("\n");
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
a1 = 3.0; b1 = 12.34; c1 = 5.0; d1 = 12.0;
SolveCubic(a1, b1, c1, d1, &solutions, x);
printf("Solutions:");
for(i=0;i<solutions;i++)
printf(" %f",x[i]);
printf("\n");
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
a1 = -8.0; b1 = -67.89; c1 = 6.0; d1 = -23.6;
SolveCubic(a1, b1, c1, d1, &solutions, x);
printf("Solutions:");
for(i=0;i<solutions;i++)
printf(" %f",x[i]);
printf("\n");
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
a1 = 45.0; b1 = 8.67; c1 = 7.5; d1 = 34.0;
SolveCubic(a1, b1, c1, d1, &solutions, x);
printf("Solutions:");
for(i=0;i<solutions;i++)
printf(" %f",x[i]);
printf("\n");
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
a1 = -12.0; b1 = -1.7; c1 = 5.3; d1 = 16.0;
SolveCubic(a1, b1, c1, d1, &solutions, x);
printf("Solutions:");
for(i=0;i<solutions;i++)
printf(" %f",x[i]);
printf("\n");
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
/* Now solve some random equations */
for(a1=1;a1<10;a1+=1) {
......@@ -79,10 +80,10 @@ int main(void)
for(c1=5;c1<15;c1+=0.61) {
for(d1=-1;d1>-5;d1-=.451) {
SolveCubic(a1, b1, c1, d1, &solutions, x);
printf("Solutions:");
for(i=0;i<solutions;i++)
printf(" %f",x[i]);
printf("\n");
/* printf("Solutions:"); */
/* for(i=0;i<solutions;i++) */
/* printf(" %f",x[i]); */
/* printf("\n"); */
}
}
}
......@@ -96,27 +97,29 @@ int main(void)
usqrt(i, &q);
// remainder differs on some machines
// printf("sqrt(%3d) = %2d, remainder = %2d\n",
printf("sqrt(%3d) = %2d\n",
i, q.sqrt);
/* printf("sqrt(%3d) = %2d\n", */
/* i, q.sqrt); */
}
printf("\n");
for (l = 0x3fed0169L; l < 0x3fed4169L; l++)
{
usqrt(l, &q);
//printf("\nsqrt(%lX) = %X, remainder = %X\n", l, q.sqrt, q.frac);
printf("sqrt(%lX) = %X\n", l, q.sqrt);
/* printf("sqrt(%lX) = %X\n", l, q.sqrt); */
}
printf("********* ANGLE CONVERSION ***********\n");
/* convert some rads to degrees */
/* for (X = 0.0; X <= 360.0; X += 1.0) */
/* for (X = 0.0; X <= 360.0; X += 1.0) */
for (X = 0.0; X <= 360.0; X += .001)
printf("%3.0f degrees = %.12f radians\n", X, deg2rad(X));
deg2rad(X);
/* printf("%3.0f degrees = %.12f radians\n", X, deg2rad(X)); */
puts("");
/* for (X = 0.0; X <= (2 * PI + 1e-6); X += (PI / 180)) */
for (X = 0.0; X <= (2 * PI + 1e-6); X += (PI / 5760))
printf("%.12f radians = %3.0f degrees\n", X, rad2deg(X));
rad2deg(X);
/* printf("%.12f radians = %3.0f degrees\n", X, rad2deg(X)); */
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment