compiler/pthread: make sure no pthread gets id equal to default value of type
[AROS.git] / test / mathffp.c
blob5d789fae0e62235a01cafd8a4e59f41f85d54f52
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /* Because fload is defined to "int" later below,
7 and we still need the real float in some places */
9 typedef float realfloat;
11 union kludge
13 realfloat f;
14 int i;
17 /* !!!! Where you see "float" later below, "int" will be
18 used instead by the compiler !!!! */
20 #define float int
22 /* Because of the define above, the math protos/defines are
23 changed in such a way that all parameters are assumed to
24 be integers and also the return value is assumed to be
25 integer !!!! */
27 #include <proto/exec.h>
28 #include <proto/mathffp.h>
29 #include <proto/mathtrans.h>
30 #include <libraries/mathffp.h>
31 #include <stdio.h>
33 struct MathBase *MathBase;
34 struct MathTransBase *MathTransBase;
36 realfloat converttofloat(float ffpfloat)
38 union kludge n;
40 n.i = ffpfloat;
41 n.i = SPTieee(n.i);
43 return n.f;
46 void domul(realfloat a, realfloat b)
48 union kludge x, y, res;
50 x.f = a;
51 x.i = SPFieee(x.i);
53 y.f = b;
54 y.i = SPFieee(y.i);
56 res.i = SPMul(x.i, y.i);
58 puts("");
59 printf("mathffp : %f x %f = %f (hex %x)\n",
60 converttofloat(x.i), converttofloat(y.i), converttofloat(res.i), res.i);
61 printf("realfloat: %f x %f = %f\n",
62 a, b, a * b);
66 int main(void)
68 MathBase = (struct MathBase *)OpenLibrary("mathffp.library", 0);
69 if (!MathBase) return;
71 /* mathtrans.library is needed for SPFieee() function to convert
72 a float to IEEE floating point format */
74 MathTransBase = (struct MathTransBase *)OpenLibrary("mathtrans.library", 0);
75 if (!MathTransBase) return;
77 domul(1.0, 0.017812);
78 domul(2.0, 0.017812);
79 domul(3.0, 0.017812);
80 domul(4.0, 0.017812);
81 domul(5.0, 0.017812);
82 domul(6.0, 0.017812);
83 domul(7.0, 0.017812);
84 domul(8.0, 0.017812);
85 domul(9.0, 0.017812);
87 CloseLibrary((struct Library *)MathTransBase);
88 CloseLibrary((struct Library *)MathBase);