diff test/float.c @ 85:3789aef7331d

minor fix
author kono
date Wed, 05 Mar 2003 13:43:52 +0900
parents 1a723130a2c7
children 4d1275f8a5b5
line wrap: on
line diff
--- a/test/float.c	Wed Mar 05 10:54:33 2003 +0900
+++ b/test/float.c	Wed Mar 05 13:43:52 2003 +0900
@@ -17,6 +17,7 @@
 main(int ac,char *av[]) {
    double g;
    int i;
+   unsigned u;
 
    g = 1.0;
    g = -g;
@@ -36,6 +37,7 @@
    if(d<d2) printf("-8 ");
    if(d<=d1) printf("9 ");
    if(d<=d2) printf("-9 ");
+   d = 123.4234; f=-234.333;
    i = d;
    d = i;
    i = f;
@@ -44,6 +46,13 @@
    f = g = d = g = d = f;
    printf(" %d %g %f %g\n",i,d,f,g);
 
+   d = 4294967295.4234; f=4294967295.4234;
+   u = d;
+   d = u;
+   u = f;
+   f = u;
+   printf("%u %g %f\n",u,d,f);
+
    print(1.0);
    print(0.1234);
    print(1.234e10);
@@ -89,29 +98,151 @@
     float f1;
     double g;
     double g1;
+    float *pf;
+    float *pf1;
+    double *pg;
+    double *pg1;
+    int n = 1;
 
     f = 1.3;
 
     g = 1.0;
     g = g+g;
+    printf("%d:%g\t",n++,g);
     g1 = g*g;
+    printf("%d:%g\t",n++,g1);
     g = g/g1;
+    printf("%d:%g\t",n++,g);
     g = g-g1;
+    printf("%d:%g\t",n++,g);
     g = sin(g1);
+    printf("%d:%g\t",n++,g);
     g = testd(g,g1);
+    printf("%d:%g\t",n++,g);
+    printf("\n");
 
     f = f+f;
+    printf("%d:%g\t",n++,f);
     f1 = f*f;
+    printf("%d:%g\t",n++,f1);
     f = f/f1;
+    printf("%d:%g\t",n++,f);
     f = f-f1;
+    printf("%d:%g\t",n++,f);
     f = sin(f1);
+    printf("%d:%g\t",n++,f);
+    printf("\n");
+
+    g = g1++ - ++g1;
+    printf("%d:%g\t",n++,g);
+
+    g = f1++ - ++f1;
+    printf("%d:%g\t",n++,g);
 
     g = f+f;
+    printf("%d:%g\t",n++,g);
     f = g*g;
+    printf("%d:%g\t",n++,f);
     f = testf(f,f1);
+    printf("%d:%g\t",n++,f);
 
     g = g*g+f*f-g1*g1;
+    printf("%d:%g\t",n++,g);
+    printf("\n");
 
-    printf("%g %g %g %g\n",g,f,g1,f1);
+    n=1;
+    f = 1.3; pf=&f; pf1=&f1;
+
+    g = 1.0; pg=&g; pg1=&g1;
+    *pg = *pg+ *pg;
+    printf("%d:%g\t",n++,*pg);
+    *pg1 = *pg**pg;
+    printf("%d:%g\t",n++,*pg1);
+    *pg = *pg/ *pg1;
+    printf("%d:%g\t",n++,*pg);
+    *pg = *pg-*pg1;
+    printf("%d:%g\t",n++,*pg);
+    *pg = sin(*pg1);
+    printf("%d:%g\t",n++,*pg);
+    *pg = testd(*pg,*pg1);
+    printf("%d:%g\t",n++,*pg);
+    printf("\n");
+
+    *pf = *pf+*pf;
+    printf("%d:%g\t",n++,*pf);
+    *pf1 = *pf**pf;
+    printf("%d:%g\t",n++,*pf1);
+    *pf = *pf/ *pf1;
+    printf("%d:%g\t",n++,*pf);
+    *pf = *pf-*pf1;
+    printf("%d:%g\t",n++,*pf);
+    *pf = sin(*pf1);
+    printf("%d:%g\t",n++,*pf);
+    printf("\n");
+
+    *pg = (*pg1)++ - ++(*pg1);
+    printf("%d:%g\t",n++,*pg);
+
+    *pg = (*pf1)++ - ++(*pf1);
+    printf("%d:%g\t",n++,*pg);
+
+    *pg = *pf+*pf;
+    printf("%d:%g\t",n++,*pg);
+    *pf = *pg**pg;
+    printf("%d:%g\t",n++,*pf);
+    *pf = testf(*pf,*pf1);
+    printf("%d:%g\t",n++,*pf);
+
+    *pg = *pg**pg+*pf**pf-*pg1**pg1;
+    printf("%d:%g\t",n++,*pg);
+    printf("\n");
+
+    n=1;
+    f = 1.3;
+    g = 1.0;
+
+    g *= 2*g;
+    printf("%d:%g\t",n++,g);
+    g /= 2*g;
+    printf("%d:%g\t",n++,g);
+    g -= 2*g;
+    printf("%d:%g\t",n++,g);
+    g += 2*g;
+    printf("%d:%g\t",n++,g);
+
+    f *= 2*g;
+    printf("%d:%g\t",n++,f);
+    f /= 2*g;
+    printf("%d:%g\t",n++,f);
+    f -= 2*g;
+    printf("%d:%g\t",n++,f);
+    f += 2*g;
+    printf("%d:%g\t",n++,f);
+    printf("\n");
+
+    n=1;
+    f = 1.3;
+    g = 1.0;
+
+    *pg *= 2**pg;
+    printf("%d:%g\t",n++,*pg);
+    *pg /= 2**pg;
+    printf("%d:%g\t",n++,*pg);
+    *pg -= 2**pg;
+    printf("%d:%g\t",n++,*pg);
+    *pg += 2**pg;
+    printf("%d:%g\t",n++,*pg);
+
+    *pf *= 2**pg;
+    printf("%d:%g\t",n++,*pf);
+    *pf /= 2**pg;
+    printf("%d:%g\t",n++,*pf);
+    *pf -= 2**pg;
+    printf("%d:%g\t",n++,*pf);
+    *pf += 2**pg;
+    printf("%d:%g\t",n++,*pf);
+    printf("\n");
+
+
     return;
 }