grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / mathieeesingtrans / intern_ieeespld.c
blob20ef875359095e999fc4aecb998ccc0dce8d39b7
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <libraries/mathieeesp.h>
7 #include <aros/libcall.h>
8 #include <proto/mathieeesingbas.h>
9 #include <proto/mathieeesingtrans.h>
10 #include <proto/exec.h>
11 #include <exec/types.h>
12 #include "mathieeesingtrans_intern.h"
14 LONG intern_IEEESPLd(ULONG fnum)
16 ULONG i = 0, Res = 0;
17 ULONG Mask = 0;
19 if (onehalf == fnum) return minusone;
21 while (Mask == 0 && i <= 23)
23 /* if (sqrtone < fnum) */
24 if ( 0x00b504f3 < ((fnum & IEEESPMantisse_Mask) | 0x00800000) )
26 i++;
27 fnum = IEEESPMul(fnum, fnum);
29 else
31 Mask = 0x40000000;
32 fnum = IEEESPMul(fnum, fnum);
33 fnum+= 0x00800000;
37 while ((char) Mask != 0x40)
39 if ( 0x00b504f3 < ((fnum & IEEESPMantisse_Mask) | 0x00800000) )
41 fnum = IEEESPMul(fnum, fnum);
43 else
45 Res |= Mask;
46 fnum = IEEESPMul(fnum, fnum);
47 fnum+= 0x00800000;
49 Mask >>= 1;
52 /* for precision */
53 if ((char) Res < 0) Res += 0x100;
55 Res >>= 8;
57 return (Res | ( (0x7e - i) << 23 ) | IEEESPSign_Mask );
58 } /* intern_SPLd */