New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / workbench / libs / mathieeedoubtrans / intern_ieeedpld.c
blob7d1633998b201b810a00d1dc49287fa63e194223
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
9 #include <aros/libcall.h>
10 #include <proto/mathieeedoubbas.h>
11 #include <proto/mathieeedoubtrans.h>
12 #include <proto/exec.h>
13 #include <exec/types.h>
14 #include "mathieeedoubtrans_intern.h"
17 QUAD intern_IEEEDPLd(struct MathIeeeDoubTransBase * MathIeeeDoubTransBase,
18 QUAD fnum)
20 QUAD tmp, Res, Mask;
21 ULONG i = 0;
23 /* argument = 0.5 -> return -1.0;*/
24 if (is_eqC(fnum, 0x3fe00000, 0x0))
26 Set_Value64C(Res, 0xbff00000, 0x0);
27 return Res;
30 Set_Value64C(Res, 0x0, 0x0);
32 while (i <= 52)
34 Set_Value64(tmp, fnum);
35 AND64QC(tmp, IEEEDPMantisse_Mask_Hi, IEEEDPMantisse_Mask_Lo);
36 OR64QC(tmp, 0x00100000, 0x0);
37 /* if (sqrtonehalf < fnum) */
38 if ( is_greaterC(tmp, 0x0016a09e, 0x667f3bcc) )
40 i++;
41 fnum = IEEEDPMul(fnum, fnum);
43 else
45 Set_Value64C(Mask, 0x40000000, 0x0);
46 fnum = IEEEDPMul(fnum, fnum);
47 ADD64QC(fnum, 0x00100000, 0x0);
48 break;
52 while (is_neqC(Mask, 0x0, 0x200))
54 Set_Value64(tmp, fnum);
55 AND64QC(tmp, IEEEDPMantisse_Mask_Hi, IEEEDPMantisse_Mask_Lo);
56 OR64QC(tmp, 0x00100000, 0x0);
57 if ( is_greaterC(tmp, 0x0016a09e, 0x667f3bcc) )
58 /* fnum = fnum*fnum */
59 fnum = IEEEDPMul(fnum, fnum);
60 else
62 OR64Q(Res, Mask);
63 /* fnum = fnum*fnum * 2 */
64 fnum = IEEEDPMul(fnum, fnum);
65 ADD64QC(fnum, 0x00100000, 0x0);
67 SHRU64(Mask, Mask, 1);
70 /* for precision */
72 if ( (Get_Low32of64(Res) & 0x400) == 0x400)
73 ADD64QC(Res, 0x0, 0x800);
75 SHRU64(Res, Res, 11);
76 OR64QC(Res, IEEEDPSign_Mask_Hi, IEEEDPSign_Mask_Lo);
77 SHL32(tmp, (0x3fe - i) , 52);
78 OR64Q(Res, tmp);
79 return Res;
80 } /* intern_IEEEDPLd */