revert between 56095 -> 55830 in arch
[AROS.git] / workbench / libs / mathieeedoubbas / ieeedpabs.c
blob2112fa1e62fcc3a942cf14e14b4c5850c7ce3980
1 /*
2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "mathieeedoubbas_intern.h"
8 /*****************************************************************************
10 NAME */
12 AROS_LHQUAD1(double, IEEEDPAbs,
14 /* SYNOPSIS */
15 AROS_LHAQUAD(double, y, D0, D1),
17 /* LOCATION */
18 struct MathIeeeDoubBasBase *, MathIeeeDoubBasBase, 9, MathIeeeDoubBas)
20 /* FUNCTION
21 Calculate the absolute value of the given IEEE double precision
22 floating point number.
24 INPUTS
25 y - IEEE double precision floating point number.
27 RESULT
28 x - absolute value of y.
30 Flags:
31 zero : result is zero
32 negative : 0
33 overflow : 0
35 NOTES
37 EXAMPLE
39 BUGS
41 SEE ALSO
42 IEEEDPNeg()
44 INTERNALS
45 Algorithm:
46 Set the sign-bit to zero.
48 *****************************************************************************/
50 AROS_LIBFUNC_INIT
52 QUAD * Qy = (QUAD *)&y;
54 /*if (0 == (*Qy)) */
55 if (is_eqC((*Qy),0,0))
57 /* value is 0 -> set the Zero Flag */
58 SetSR( Zero_Bit, Zero_Bit | Overflow_Bit | Negative_Bit);
60 else
62 /* set the sign-bit to zero */
63 /* (*Qy) &= (IEEEDPMantisse_Mask | IEEEDPExponent_Mask) */
64 AND64QC
66 (*Qy),
67 (IEEEDPMantisse_Mask_Hi | IEEEDPExponent_Mask_Hi),
68 (IEEEDPMantisse_Mask_Lo | IEEEDPExponent_Mask_Lo)
70 SetSR(0, Zero_Bit | Overflow_Bit | Negative_Bit );
73 return y;
75 AROS_LIBFUNC_EXIT