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