1floatabs(float x)
2{
3if(x<0) x=0-x;
4return x;
5}
6
7
8floatsin(float x)
9
10{
11
12constfloat B = 1.2732395447; 13constfloat C = -0.4052847346;
14constfloat P = 0.2310792853;//0.225; 15float y = B * x + C * x * abs(x); 16 y = P * (y * abs(y) - y) + y; 17return y;
18 }
19
20
21floatcos(float x)
22{
23constfloat Q = 1.5707963268; 24constfloat PI =3.1415926536; 25 x += Q;
26
27if(x > PI)
28 x -= 2 * PI;
29
30return( sin(x));
31}
32
33
34floatsqrt(float a)
35 {
36doublex,y;
37 x=0.0;
38 y=a/2;
39while(x!=y)
40 {
41 x=y;
42 y=(x+a/x)/2;
43 }
44return x;
45 }
46
47
48floatpow(floata,int b) 49{
50float r=a;
51if(b>0)
52 {
53while(--b)
54 r*=a; 55
56 }
57elseif(b<0)
58 {
59while(++b) r*=a; 60 r=1.0/r; 61 }
…… …… 余下全文