quad_float.h revision 1.4
1/*	$OpenBSD: quad_float.h,v 1.4 2000/01/11 08:18:43 mickey Exp $	*/
2
3/*
4 * Copyright 1996 1995 by Open Software Foundation, Inc.
5 *              All Rights Reserved
6 *
7 * Permission to use, copy, modify, and distribute this software and
8 * its documentation for any purpose and without fee is hereby granted,
9 * provided that the above copyright notice appears in all copies and
10 * that both the copyright notice and this permission notice appear in
11 * supporting documentation.
12 *
13 * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
14 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
15 * FOR A PARTICULAR PURPOSE.
16 *
17 * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
18 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
19 * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
20 * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
21 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22 *
23 */
24/*
25 * pmk1.1
26 */
27/*
28 * (c) Copyright 1986 HEWLETT-PACKARD COMPANY
29 *
30 * To anyone who acknowledges that this file is provided "AS IS"
31 * without any express or implied warranty:
32 *     permission to use, copy, modify, and distribute this file
33 * for any purpose is hereby granted without fee, provided that
34 * the above copyright notice and this notice appears in all
35 * copies, and that the name of Hewlett-Packard Company not be
36 * used in advertising or publicity pertaining to distribution
37 * of the software without specific, written prior permission.
38 * Hewlett-Packard Company makes no representations about the
39 * suitability of this software for any purpose.
40 */
41
42/******************************
43 *  Quad precision functions  *
44 ******************************/
45
46/* 32-bit word grabing functions */
47#define Quad_firstword(value) Qallp1(value)
48#define Quad_secondword(value) Qallp2(value)
49#define Quad_thirdword(value)  Qallp3(value)
50#define Quad_fourthword(value)  Qallp4(value)
51
52
53/* This magnitude comparison uses the signless first words and
54 * the regular part2 words.  The comparison is graphically:
55 *
56 *       1st greater?  ----------->|
57 *                                 |
58 *       1st less?-----------------+------->|
59 *                                 |        |
60 *       2nd greater?------------->|        |
61 *                                 |        |
62 *       2nd less?-----------------+------->|
63 *                                 |        |
64 *       3rd greater?------------->|        |
65 *                                 |        |
66 *       3rd less?-----------------+------->|
67 *                                 |        |
68 *       4th greater or equal?---->|        |
69 *                                 |        |
70 *                               False     True
71 */
72#define Quad_ismagnitudeless(leftp3,leftp4,rightp1,rightp2,rightp3,rightp4,signlessleft,signlessright) \
73/*  Quad_floating_point left, right;          *				\
74 *  unsigned int signlessleft, signlessright; */			\
75      ( signlessleft<=signlessright &&					\
76       (signlessleft<signlessright || (Qallp2(leftp2)<=Qallp2(rightp2) && \
77        (Qallp2(leftp2)<Qallp2(rightp2) || (Qallp3(leftp3)<=Qallp3(rightp3) && \
78	 (Qallp3(leftp3)<Qallp3(rightp3) || Qallp4(leftp4)<Qallp4(rightp4)))))))
79
80#define Quad_xor_to_intp1(leftp1,rightp1,result)		\
81    /* quad_floating_point left, right;				\
82     * unsigned int result; */					\
83    result = Qallp1(leftp1) XOR Qallp1(rightp1);
84
85#define Quad_xor_from_intp1(leftp1,rightp1,result)		\
86    /* quad_floating_point right, result;			\
87     * unsigned int left; */					\
88    Qallp1(resultp1) = left XOR Qallp1(rightp1)
89
90#define Quad_swap_lower(leftp1,leftp2,leftp3,leftp4,rightp1,rightp2,rightp3,rightp4)  \
91    /* quad_floating_point left, right; */			\
92    Qallp2(leftp2)  = Qallp2(leftp2) XOR Qallp2(rightp2)	\
93    Qallp2(rightp2) = Qallp2(leftp2) XOR Qallp2(rightp2)	\
94    Qallp2(leftp2)  = Qallp2(leftp2) XOR Qallp2(rightp2)	\
95    Qallp3(leftp3)  = Qallp3(leftp3) XOR Qallp3(rightp3)	\
96    Qallp3(rightp3) = Qallp3(leftp3) XOR Qallp3(rightp3)	\
97    Qallp3(leftp3)  = Qallp3(leftp3) XOR Qallp3(rightp3)	\
98    Qallp4(leftp4)  = Qallp4(leftp4) XOR Qallp4(rightp4)	\
99    Qallp4(rightp4) = Qallp4(leftp4) XOR Qallp4(rightp4)	\
100    Qallp4(leftp4)  = Qallp4(leftp4) XOR Qallp4(rightp4)
101
102int quad_frnd __P((quad_floating_point *, quad_floating_point *, unsigned int *));
103