Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / mathieeedoubbas / ieeedpflt.c
blob9515087ddfa3797e35ef323ccf6d69871b4d5b0a
1 /*
2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathieeedoubbas_intern.h"
8 /*
9 FUNCTION
12 RESULT
13 IEEE double precision number
15 Flags:
16 zero : result is zero
17 negative : result is negative
18 overflow : 0
20 NOTES
22 EXAMPLE
24 BUGS
26 SEE ALSO
28 INTERNALS
30 HISTORY
33 AROS_LHQUAD1(double, IEEEDPFlt,
34 AROS_LHAQUAD(LONG, y, D0, D1),
35 struct MathIeeeDoubBasBase *, MathIeeeDoubBasBase, 6, MathIeeeDoubBas
38 AROS_LIBFUNC_INIT
40 LONG Exponent = 0;
41 LONG TestMask = 0xFFFFFFFF;
42 QUAD Res, yQuad, ExponentQuad;
43 double * DRes = (double *)&Res;
45 Set_Value64C(Res,0,0);
47 if (0 == y)
49 SetSR(Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
50 return *DRes; /* return 0 */
53 if (y < 0 )
55 Set_Value64C(Res, IEEEDPSign_Mask_Hi, IEEEDPSign_Mask_Lo);
56 y = -y;
58 /* find out which is the number of the highest set bit */
59 while (TestMask & y)
61 Exponent ++;
62 TestMask <<= 1;
65 SHL32(yQuad , y , (53 - Exponent) );
67 AND64QC(yQuad, IEEEDPMantisse_Mask_Hi, IEEEDPMantisse_Mask_Lo);
69 Exponent += 0x3fe;
71 /* adapt Exponent to IEEEDP-Format */
72 SHL32(ExponentQuad, Exponent, 52);
73 OR64Q(Res, yQuad);
74 OR64Q(Res, ExponentQuad);
75 if ( is_lessSC(Res,0,0) ) /* Res < 0 */
77 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
80 return *DRes;
82 AROS_LIBFUNC_EXIT