Use 'mail' instead of 'mutt', since it's more readily available and
[tangerine.git] / test / mathffp.c
blob92d5c32626fcb72ffe93b5c725d64f5ab013d477
1 /* Because fload is defined to "int" later below,
2 and we still need the real float in some places */
4 typedef float realfloat;
6 union kludge
8 realfloat f;
9 int i;
12 /* !!!! Where you see "float" later below, "int" will be
13 used instead by the compiler !!!! */
15 #define float int
17 /* Because of the define above, the math protos/defines are
18 changed in such a way that all parameters are assumed to
19 be integers and also the return value is assumed to be
20 integer !!!! */
22 #include <proto/exec.h>
23 #include <proto/mathffp.h>
24 #include <proto/mathtrans.h>
25 #include <libraries/mathffp.h>
26 #include <stdio.h>
28 struct MathBase *MathBase;
29 struct MathTransBase *MathTransBase;
31 realfloat converttofloat(float ffpfloat)
33 union kludge n;
35 n.i = ffpfloat;
36 n.i = SPTieee(n.i);
38 return n.f;
41 void domul(realfloat a, realfloat b)
43 union kludge x, y, res;
45 x.f = a;
46 x.i = SPFieee(x.i);
48 y.f = b;
49 y.i = SPFieee(y.i);
51 res.i = SPMul(x.i, y.i);
53 puts("");
54 printf("mathffp : %f x %f = %f (hex %x)\n",
55 converttofloat(x.i), converttofloat(y.i), converttofloat(res.i), res.i);
56 printf("realfloat: %f x %f = %f\n",
57 a, b, a * b);
61 int main(void)
63 MathBase = (struct MathBase *)OpenLibrary("mathffp.library", 0);
64 if (!MathBase) return;
66 /* mathtrans.library is needed for SPFieee() function to convert
67 a float to IEEE floating point format */
69 MathTransBase = (struct MathTransBase *)OpenLibrary("mathtrans.library", 0);
70 if (!MathTransBase) return;
72 domul(1.0, 0.017812);
73 domul(2.0, 0.017812);
74 domul(3.0, 0.017812);
75 domul(4.0, 0.017812);
76 domul(5.0, 0.017812);
77 domul(6.0, 0.017812);
78 domul(7.0, 0.017812);
79 domul(8.0, 0.017812);
80 domul(9.0, 0.017812);
82 CloseLibrary((struct Library *)MathTransBase);
83 CloseLibrary((struct Library *)MathBase);