Mercurial > hg > CbC > old > device
view test/float.c @ 84:1a723130a2c7
condtional
author | kono |
---|---|
date | Wed, 05 Mar 2003 10:54:33 +0900 |
parents | 25654dc29ecc |
children | 3789aef7331d |
line wrap: on
line source
#include "stdio.h" void test2(double); void test1(); void print(double d); extern double sin(double); // extern float fsin(float); float f = 0.3; double d = 0.3; float f1 = 0.3; double d1 = 0.3; double d2 = -0.2; int main(int ac,char *av[]) { double g; int i; g = 1.0; g = -g; printf("%g\ncond ",g); if(f==f*1.0) printf("1 "); if(d==f*1.0) printf("2 "); if(f==f1) printf("3 "); if(d==d1) printf("4 "); if(d==d2) printf("-4 "); if(d>d1) printf("5 "); if(d>d2) printf("-5 "); if(d>=d1) printf("6 "); if(d>=d2) printf("-6 "); if(d!=d1) printf("7 "); if(d!=d2) printf("-7 "); if(d<d1) printf("8 "); if(d<d2) printf("-8 "); if(d<=d1) printf("9 "); if(d<=d2) printf("-9 "); i = d; d = i; i = f; f = i; printf("\n%d %g %f",i,d,f); f = g = d = g = d = f; printf(" %d %g %f %g\n",i,d,f,g); print(1.0); print(0.1234); print(1.234e10); print(1.234e-10); test1(); return 0; } void print(double d) { float f; int *dd; f = d; dd = (int*) &d; printf("d %g ",d); printf("dx %08x %08x\n",*(dd),*(dd+1)); dd = (int*) &f; printf("f %g ",f); printf("dx %08x \n",*(dd)); } double testd(double i,double j) { return i+1.1+.0e3+12.3e-12; } float testf(float i,float j) { return i+1; } void test1() { float f; float f1; double g; double g1; f = 1.3; g = 1.0; g = g+g; g1 = g*g; g = g/g1; g = g-g1; g = sin(g1); g = testd(g,g1); f = f+f; f1 = f*f; f = f/f1; f = f-f1; f = sin(f1); g = f+f; f = g*g; f = testf(f,f1); g = g*g+f*f-g1*g1; printf("%g %g %g %g\n",g,f,g1,f1); return; }