projects
/
my-code
/
atmel.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
-> mapping to an 1/x like behaviour
[my-code/atmel.git]
/
beginners
/
oneoverx.c
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include <math.h>
4
5
int main(int argc,char **argv) {
6
7
int i;
8
9
double c,a,o,f;
10
11
a=atof(argv[1]);
12
c=(1.0-sqrt(1+4*a))/2.0; // -!
13
o=a/(1-c);
14
15
printf("; f(x) = a / (x+o) + c (a:%f o:%f c:%f)\n",a,o,c);
16
17
for(i=255;i>=0;i--) {
18
f=a/(1.0*i/255+o)+c;
19
printf("; %d - %d\n",255-i,255-i+1);
20
printf(".db 0x%0x, ",(int)(f*255));
21
i-=1;
22
f=a/(1.0*i/255+o)+c;
23
printf("0x%0x\n",(int)(f*255));
24
}
25
26
return 0;
27
}
28