grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / mathtrans / intern_spld.c
blob5444fa5fad4a07d7a79daef75b5d9e8883058ad7
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
7 #include <libraries/mathffp.h>
8 #include <aros/libcall.h>
9 #include <proto/mathffp.h>
10 #include <proto/mathtrans.h>
11 #include <exec/types.h>
12 #include "mathtrans_intern.h"
14 LONG intern_SPLd(ULONG fnum)
16 ULONG i = 0, Res = 0, c;
17 ULONG Mask = 0x80000000;
19 if (onehalf == fnum) return minusone;
21 while (Res == 0 && i <= 23)
23 if ( sqrtonehalf < fnum)
25 i++;
26 fnum = SPMul(fnum, fnum);
28 else
30 Res = Mask;
31 Mask >>= 1;
32 fnum = SPMul(fnum, fnum);
33 fnum++;
37 c = i;
39 while ((char) Mask != 0x40 && c < 24 )
41 if ( sqrtonehalf < fnum )
43 fnum = SPMul(fnum, fnum);
45 else
47 Res |= Mask;
48 fnum = SPMul(fnum, fnum);
49 fnum++;
51 c++;
52 Mask >>= 1;
55 /* for precision */
56 if ((char) Res < 0)
58 Res += 0x100;
59 Res &= FFPMantisse_Mask;
62 return (Res | (0x40-i) | FFPSign_Mask);
63 } /* intern_SPLd */