1 /* $OpenBSD: fpu_q.c,v 1.2 2004/02/03 17:18:13 jason Exp $ */
2
3 /*
4 * Copyright (c) 2003 Jason L. Wright (jason@thought.net)
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
24 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include <sys/types.h>
30 #include "fpu_q.h"
31
32 long double
_Q_mul(long double a,long double b)33 _Q_mul(long double a, long double b)
34 {
35 long double c;
36
37 _Qp_mul(&c, &a, &b);
38 return (c);
39 }
40
41 long double
_Q_div(long double a,long double b)42 _Q_div(long double a, long double b)
43 {
44 long double c;
45
46 _Qp_div(&c, &a, &b);
47 return (c);
48 }
49
50 long double
_Q_sub(long double a,long double b)51 _Q_sub(long double a, long double b)
52 {
53 long double c;
54
55 _Qp_sub(&c, &a, &b);
56 return (c);
57 }
58
59 long double
_Q_add(long double a,long double b)60 _Q_add(long double a, long double b)
61 {
62 long double c;
63
64 _Qp_add(&c, &a, &b);
65 return (c);
66 }
67
68 long double
_Q_neg(long double a)69 _Q_neg(long double a)
70 {
71 long double z = 0, r;
72
73 _Qp_sub(&r, &z, &a);
74 return (r);
75 }
76
77 long double
_Q_sqrt(long double a)78 _Q_sqrt(long double a)
79 {
80 long double v;
81
82 _Qp_sqrt(&v, &a);
83 return (v);
84 }
85
86 long double
_Q_dtoq(double a)87 _Q_dtoq(double a)
88 {
89 long double v;
90
91 _Qp_dtoq(&v, a);
92 return (v);
93 }
94
95 long double
_Q_stoq(float a)96 _Q_stoq(float a)
97 {
98 long double v;
99
100 _Qp_stoq(&v, a);
101 return (v);
102 }
103
104 long double
_Q_itoq(int a)105 _Q_itoq(int a)
106 {
107 long double v;
108
109 _Qp_itoq(&v, a);
110 return (v);
111 }
112
113 long double
_Q_utoq(unsigned int a)114 _Q_utoq(unsigned int a)
115 {
116 long double v;
117
118 _Qp_uitoq(&v, a);
119 return (v);
120 }
121
122 double
_Q_qtod(long double a)123 _Q_qtod(long double a)
124 {
125 double v;
126
127 v = _Qp_qtod(&a);
128 return (v);
129 }
130
131 int
_Q_qtoi(long double a)132 _Q_qtoi(long double a)
133 {
134 int v;
135
136 v = _Qp_qtoi(&a);
137 return (v);
138 }
139
140 float
_Q_qtos(long double a)141 _Q_qtos(long double a)
142 {
143 float v;
144
145 v = _Qp_qtos(&a);
146 return (v);
147 }
148
149 unsigned int
_Q_qtou(long double a)150 _Q_qtou(long double a)
151 {
152 unsigned int v;
153
154 v = _Qp_qtoui(&a);
155 return (v);
156 }
157
158 int
_Q_feq(long double a,long double b)159 _Q_feq(long double a, long double b)
160 {
161 return (_Qp_feq(&a, &b));
162 }
163
164 int
_Q_fne(long double a,long double b)165 _Q_fne(long double a, long double b)
166 {
167 return (_Qp_fne(&a, &b));
168 }
169
170 int
_Q_fge(long double a,long double b)171 _Q_fge(long double a, long double b)
172 {
173 return (_Qp_fge(&a, &b));
174 }
175
176 int
_Q_fgt(long double a,long double b)177 _Q_fgt(long double a, long double b)
178 {
179 return (_Qp_fgt(&a, &b));
180 }
181
182 int
_Q_flt(long double a,long double b)183 _Q_flt(long double a, long double b)
184 {
185 return (_Qp_flt(&a, &b));
186 }
187
188 int
_Q_fle(long double a,long double b)189 _Q_fle(long double a, long double b)
190 {
191 return (_Qp_fle(&a, &b));
192 }
193