modified: src1/worker.c
[GalaxyCodeBases.git] / c_cpp / readscorr / tester.c
blob654b10a54d93e9e03d77e929dac249e5d09ac423
1 #define _GNU_SOURCE
2 #include "gtypendef.h"
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <stdint.h>
6 #include <string.h>
7 //#include <errno.h>
8 #include <err.h>
9 #include <argp.h>
10 #include "MurmurHash3.h"
11 #include "getch.h"
12 #include "2bitarray.h"
13 #include "gFileIO.h"
14 #include "sdleft.h"
15 #include "chrseq.h"
17 // http://www.mersenneforum.org/showthread.php?t=14419
18 #include <endian.h>
20 typedef union
22 __float128 val;
23 float128 ourval;
24 struct
26 #if __BYTE_ORDER == __BIG_ENDIAN
27 uint64_t sign : 1;
28 uint64_t exp : 15;
29 uint64_t frac1 : 48;
30 uint64_t frac0 : 64;
31 #else
32 uint64_t frac0 : 64;
33 uint64_t frac1 : 48;
34 uint64_t exp : 15;
35 uint64_t sign : 1;
36 #endif
37 } bits;
38 } qfloat;
41 void test_types(void) {
42 union {
43 uint128_t u128;
44 uint64_t u64[2];
45 } test1;
46 test1.u128 = 16u+(uint128_t)UINT64_MAX*65536u;
47 printf("uint128_t [%lx %lx]\n",test1.u64[1],test1.u64[0]);
48 // http://www.mersenneforum.org/showthread.php?t=14419
49 qfloat foo;
50 qfloat bar;
51 foo.val = 65536.0;
52 foo.val += 1.0;
53 foo.val *= foo.val;
54 bar.ourval = (__float128)1/(__float128)3;
55 printf("%04X %012lX %016lX\n", (uint16_t)foo.bits.exp, (uint64_t)foo.bits.frac1, foo.bits.frac0);
56 printf("%04X %012lX %016lX\n", (uint16_t)bar.bits.exp, (uint64_t)bar.bits.frac1, bar.bits.frac0);
59 void test_baseswitcher(void) {
60 const unsigned char baseswitcher[]={
61 4,0,4,1,4, // 64-68
62 4,4,2,4,4, // 69-73
63 4,4,4,4,4, // 74-78
64 4,4,4,4,4, // 79-83
65 3 // 84
67 char *seq="ATCGatcgNn";
68 while (*seq) {
69 printf("%c -> %u\n",*seq,baseswitcher[*seq-64]);
70 ++seq;
74 int main(void) {
75 test_types();
76 test_baseswitcher();
77 return 0;