Mercurial > hg > CbC > old > device
view test/long.c @ 423:8b9136a06f56
bitfield continue...
author | kono |
---|---|
date | Fri, 29 Oct 2004 14:20:19 +0900 |
parents | 3e8ba7024d25 |
children | 0c256ea2a97e |
line wrap: on
line source
long long gj; long long gi; long long a[100]; unsigned long long b[100]; unsigned long long c[100]; long long data[] = {2342342342304234LL,2342342340234234LL, -234234342340234LL, -2342342342340234LL }; unsigned long long udata[] = {2342342334234LL,23423423434234LL, -23423423234234LL, -234234234234234LL}; long long f(long long i,unsigned long long j,unsigned long long k,long long m,long long a); unsigned long long g(long long i,unsigned long long j,unsigned long long k,long long m,long long a); void test3(); float f2ll(long long i) { float r; r = i ; return r; } double d2ll(long long i) { double r; r = i ; return r; } float f2ull(unsigned long long i) { float r; r = i ; return r; } double d2ull(unsigned long long i) { double r; r = i ; return r; } long long ll2f(float f) { long long r; r = f ; return r; } long long ll2d(double d) { long long r; r = d ; return r; } unsigned long long ull2f(float f) { unsigned long long r; r = f ; return r; } unsigned long long ull2d(double d) { unsigned long long r; r = d ; return r; } main() { long long int ii; long long i,k,*p; unsigned long long j,m,*up; unsigned long long g0,h0; long long g1,h1; unsigned long long sg0,sh0; long long sg1,sh1; unsigned long long *pg0,*ph0; long long *pg1,*ph1; unsigned long long *psg0,*psh0; long long *psg1,*psh1; i = -2343423423424234234LL; j = 3424223422342234224LL; k = 44; k = i*j+3+k; m = i*j-7+k; printf("%lld %lld %llu\n",i,k,m); printf("%lld %lld %llu\n",i,1231234234233LL,m); printf("0x%llx 0x%llx 0x%llx\n",i,k,m); printf("0x%llx 0x%llx 0x%llx\n",i,1231234234233LL,m); g0 = -2343423423424234234LL; g0++; --g0; ++g0; g0--; printf("g0=%lld\n",g0); printf("g0=0x%llx\n",g0); g1 = -2343423423424234234LL; g1++; --g1; ++g1; g1--; printf("g1=%lld\n",g1); printf("g1=0x%llx\n",g1); sg0 = 2343423423424234234LL; sg0++; --sg0; ++sg0; sg0--; printf("sg0=%lld\n",sg0); sg1 = -2343423423424234234LL; sg1++; --sg1; ++sg1; sg1--; printf("sg1=%lld\n",sg1); pg0 = &g0; ph0 = &h0; *pg0 = -2343423423424234234LL; //*pg0++; *--pg0; //*++pg0; *g0--; printf("g0=%lld\n",*pg0); pg1 = &g1; ph1 = &h1; *pg1 = -2343423423424234234LL; //*pg1++; --*pg1; //++*pg1; *pg1--; printf("g1=%lld\n",*pg1); psg0 = &sg0; psh0 = &sh0; *psg0 = -2343423423424234234LL; //*sg0++; *--sg0; //*++sg0; *sg0--; printf("sg0=%lld\n",*psg0); psg1 = &sg1; psh1 = &sh1; *psg1 = -2343423423424234234LL; //*sg1++; *--sg1; //*++sg1; *sg1--; printf("sg1=%lld\n",*psg1); h0 = g0 - 20; c[33] = g0; if (i==j) { printf("i==j\n"); } else { printf("i!=j\n"); } a[33] = i; b[33] = 2342342342342342342LL; printf("i=%lld\n",i); printf("j=%lld\n",j); i++; --i; j++; --j; printf("i=%lld\n",i); printf("j=%lld\n",j); gi = 2342342342342342342LL; gj = 2342342342342342342LL; gi++; --gi; gj++; --gj; printf("gi=%lld\n",gi); printf("gj=%lld\n",gj); printf("k=%lld\n",k); printf("m=%lld\n",m); printf("k=0x%llx\n",k); printf("m=0x%llx\n",m); printf("a[33]=%lld\n",a[33]); printf("b[33]=%lld\n",b[33]); printf("a[33]=%lld\n",++a[33]); printf("b[33]=%lld\n",b[33]--); printf("g0=%lld\n",g0); printf("h0=%lld\n",h0); printf("c[33]=%lld\n",c[33]); p = data; printf("*p++ = %lld\n",*p++); printf("*++p = %lld\n",*++p); *p++ = -2342342342342342342LL; printf("*p-- = %lld\n",*p--); printf("*--p = %lld\n",*--p); up = udata; printf("*up-- = %lld\n",*up--); printf("*--up = %lld\n",*--up); *up++ = 65530; printf("*up-- = %lld\n",*up--); printf("*--up = %lld\n",*--up); printf("f(%lld %llu %llu %lld %lld)\n",i,j,k,m,a[33]); ii = f(i,j,k,m,a[33]); printf("f()=%lld\n",ii); printf("f()=0x%llx\n",ii); ii = g(i,j,k,m,a[33]); printf("g()=%lld\n",ii); printf("g()=0x%llx\n",ii); test3(); return 0; } long long f(long long i,unsigned long long j,unsigned long long k,long long m,long long a) { printf("f(%lld %llu %llu %lld %lld)\n",i,j,k,m,a); return i+j*k-m/a; } unsigned long long g(long long i,unsigned long long j,unsigned long long k,long long m,long long a) { return i+j*k-m/a; } void test3() { printf("test3-1:%g\ntest3-2:%g\ntest3-3:%g\ntest3-4:%g\ntest3-5:%lld\ntest3-6:%lld\ntest3-7:%llu\ntest3-8:%llu\n", f2ll((long long ) -3423423234234LL), d2ll((long long ) -3423423234234LL), f2ull((unsigned long long ) 34234234234234LL), d2ull((unsigned long long ) 34234234234234LL), ll2f((float ) 2342423423423424234LL), ll2d((double ) 2344234234244234234LL), ull2f((float ) 2344234234244234234LL), ull2d((double )2332342343234234234LL) ); }