diff options
Diffstat (limited to 'test/test.c')
-rw-r--r-- | test/test.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/test.c b/test/test.c new file mode 100644 index 0000000..bdc11fc --- /dev/null +++ b/test/test.c @@ -0,0 +1,45 @@ +#include <stdio.h> +#include <stdint.h> + +// typedef uint32_t SF; +// const int ush=24,ssh=31; +typedef uint16_t SF; +const int ush=11,ssh=15; + +SF mul(SF a,SF b){ + SF sg=1; + if(a>=(1<<ssh)){a=-a; sg*=-1;} + if(b>=(1<<ssh)){b=-b; sg*=-1;} + return sg*(SF)(((uint64_t)a*(uint64_t)b)>>ush); +} + +SF mk(int i){ + return i<<ush; +} + +float flt(SF a){ + float sg=1; + if(a>=(1<<ssh)){a=-a; sg*=-1;} + return (float)a/(float)(1<<ush)*sg; +} + +int main(void){ + const SF L=mk(-2),R=mk(1); + const SF T=mk(1),B=-(mk(1)); + for(SF y=T;y!=B-(mk(1)>>4);y-=mk(1)>>4){ + for(SF x=L;x!=R;x+=mk(1)>>5){ + int n=0; + SF a=x,b=y,a2=mul(a,a),b2=mul(b,b); + while(n<26&&a2+b2<mk(4)){ + b=mul(mk(2),mul(a,b))+y; + a=a2-b2+x; + a2=mul(a,a); + b2=mul(b,b); + n++; + } + if(n==26)putchar(' '); + else putchar('A'+n); + } + putchar('\n'); + } +} |