Improved AutoDocs.
[AROS.git] / workbench / libs / mathieeedoubbas / ieeedpneg.c
blob78760aa75474b9a23af90df3eb3c788e1e3abc5a
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, IEEEDPNeg,
14 /* SYNOPSIS */
15 AROS_LHAQUAD(double, y, D0, D1),
17 /* LOCATION */
18 struct MathIeeeDoubBasBase *, MathIeeeDoubBasBase, 10, MathIeeeDoubBas)
20 /* FUNCTION
21 Switches the sign of the given IEEE double precision floating point
22 number.
24 INPUTS
25 y - IEEE double precision floating point number.
27 RESULT
28 x - the negation of y.
30 Flags:
31 zero : result is zero
32 negative : result is negative
33 overflow : 0
35 NOTES
37 EXAMPLE
39 BUGS
41 SEE ALSO
42 IEEEDPAbs()
44 INTERNALS
45 Algorithm:
46 Flip the sign-bit (even for zeroes).
48 *****************************************************************************/
50 AROS_LIBFUNC_INIT
52 QUAD * Qy = (QUAD *)&y;
54 /* change the sign-bit */
55 XOR64QC(*Qy, IEEEDPSign_Mask_Hi, IEEEDPSign_Mask_Lo);
59 is_eqC(*Qy, 0x0, 0x0 )
60 || is_eqC(*Qy, IEEEDPSign_Mask_Hi, IEEEDPSign_Mask_Lo)
63 SetSR( Zero_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
64 return y;
67 /* if (y < 0) */
68 if(is_lessSC(*Qy, 0x0, 0x0) )
70 /* result is negative */
71 SetSR(Negative_Bit, Zero_Bit | Negative_Bit | Overflow_Bit);
73 else
75 /* result is positive */
76 SetSR(0, Zero_Bit | Overflow_Bit | Negative_Bit );
79 return y;
81 AROS_LIBFUNC_EXIT