1 |
|
---|
2 | /*============================================================================
|
---|
3 |
|
---|
4 | This C source file is part of TestFloat, Release 3e, a package of programs for
|
---|
5 | testing the correctness of floating-point arithmetic complying with the IEEE
|
---|
6 | Standard for Floating-Point, by John R. Hauser.
|
---|
7 |
|
---|
8 | Copyright 2011, 2012, 2013, 2014, 2017 The Regents of the University of
|
---|
9 | California. All rights reserved.
|
---|
10 |
|
---|
11 | Redistribution and use in source and binary forms, with or without
|
---|
12 | modification, are permitted provided that the following conditions are met:
|
---|
13 |
|
---|
14 | 1. Redistributions of source code must retain the above copyright notice,
|
---|
15 | this list of conditions, and the following disclaimer.
|
---|
16 |
|
---|
17 | 2. Redistributions in binary form must reproduce the above copyright notice,
|
---|
18 | this list of conditions, and the following disclaimer in the documentation
|
---|
19 | and/or other materials provided with the distribution.
|
---|
20 |
|
---|
21 | 3. Neither the name of the University nor the names of its contributors may
|
---|
22 | be used to endorse or promote products derived from this software without
|
---|
23 | specific prior written permission.
|
---|
24 |
|
---|
25 | THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
|
---|
26 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
---|
27 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
|
---|
28 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
|
---|
29 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
---|
30 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
---|
31 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
---|
32 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
33 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
---|
34 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
35 |
|
---|
36 | =============================================================================*/
|
---|
37 |
|
---|
38 | #include <stdbool.h>
|
---|
39 | #include <stdint.h>
|
---|
40 | #include <fenv.h>
|
---|
41 | #include <math.h>
|
---|
42 | #include "platform.h"
|
---|
43 | #include "softfloat.h"
|
---|
44 | #include "subjfloat_config.h"
|
---|
45 | #include "subjfloat.h"
|
---|
46 |
|
---|
47 | #pragma STDC FENV_ACCESS ON
|
---|
48 |
|
---|
49 | void subjfloat_setRoundingMode( uint_fast8_t roundingMode )
|
---|
50 | {
|
---|
51 |
|
---|
52 | fesetround(
|
---|
53 | (roundingMode == softfloat_round_near_even) ? FE_TONEAREST
|
---|
54 | : (roundingMode == softfloat_round_minMag) ? FE_TOWARDZERO
|
---|
55 | : (roundingMode == softfloat_round_min) ? FE_DOWNWARD
|
---|
56 | : FE_UPWARD
|
---|
57 | );
|
---|
58 |
|
---|
59 | }
|
---|
60 |
|
---|
61 | void subjfloat_setExtF80RoundingPrecision( uint_fast8_t roundingPrecision )
|
---|
62 | {
|
---|
63 |
|
---|
64 | }
|
---|
65 |
|
---|
66 | uint_fast8_t subjfloat_clearExceptionFlags( void )
|
---|
67 | {
|
---|
68 | int subjExceptionFlags;
|
---|
69 | uint_fast8_t exceptionFlags;
|
---|
70 |
|
---|
71 | subjExceptionFlags =
|
---|
72 | fetestexcept(
|
---|
73 | FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT
|
---|
74 | );
|
---|
75 | feclearexcept(
|
---|
76 | FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT );
|
---|
77 | exceptionFlags = 0;
|
---|
78 | if ( subjExceptionFlags & FE_INVALID ) {
|
---|
79 | exceptionFlags |= softfloat_flag_invalid;
|
---|
80 | }
|
---|
81 | if ( subjExceptionFlags & FE_DIVBYZERO ) {
|
---|
82 | exceptionFlags |= softfloat_flag_infinite;
|
---|
83 | }
|
---|
84 | if ( subjExceptionFlags & FE_OVERFLOW ) {
|
---|
85 | exceptionFlags |= softfloat_flag_overflow;
|
---|
86 | }
|
---|
87 | if ( subjExceptionFlags & FE_UNDERFLOW ) {
|
---|
88 | exceptionFlags |= softfloat_flag_underflow;
|
---|
89 | }
|
---|
90 | if ( subjExceptionFlags & FE_INEXACT ) {
|
---|
91 | exceptionFlags |= softfloat_flag_inexact;
|
---|
92 | }
|
---|
93 | return exceptionFlags;
|
---|
94 |
|
---|
95 | }
|
---|
96 |
|
---|
97 | union f32_f { float32_t f32; float f; };
|
---|
98 |
|
---|
99 | float32_t subj_ui32_to_f32( uint32_t a )
|
---|
100 | {
|
---|
101 | union f32_f uZ;
|
---|
102 |
|
---|
103 | uZ.f = a;
|
---|
104 | return uZ.f32;
|
---|
105 |
|
---|
106 | }
|
---|
107 |
|
---|
108 | float32_t subj_ui64_to_f32( uint64_t a )
|
---|
109 | {
|
---|
110 | union f32_f uZ;
|
---|
111 |
|
---|
112 | uZ.f = a;
|
---|
113 | return uZ.f32;
|
---|
114 |
|
---|
115 | }
|
---|
116 |
|
---|
117 | float32_t subj_i32_to_f32( int32_t a )
|
---|
118 | {
|
---|
119 | union f32_f uZ;
|
---|
120 |
|
---|
121 | uZ.f = a;
|
---|
122 | return uZ.f32;
|
---|
123 |
|
---|
124 | }
|
---|
125 |
|
---|
126 | float32_t subj_i64_to_f32( int64_t a )
|
---|
127 | {
|
---|
128 | union f32_f uZ;
|
---|
129 |
|
---|
130 | uZ.f = a;
|
---|
131 | return uZ.f32;
|
---|
132 |
|
---|
133 | }
|
---|
134 |
|
---|
135 | uint_fast32_t subj_f32_to_ui32_rx_minMag( float32_t a )
|
---|
136 | {
|
---|
137 | union f32_f uA;
|
---|
138 |
|
---|
139 | uA.f32 = a;
|
---|
140 | return (uint32_t) uA.f;
|
---|
141 |
|
---|
142 | }
|
---|
143 |
|
---|
144 | uint_fast64_t subj_f32_to_ui64_rx_minMag( float32_t a )
|
---|
145 | {
|
---|
146 | union f32_f uA;
|
---|
147 |
|
---|
148 | uA.f32 = a;
|
---|
149 | return (uint64_t) uA.f;
|
---|
150 |
|
---|
151 | }
|
---|
152 |
|
---|
153 | int_fast32_t subj_f32_to_i32_rx_minMag( float32_t a )
|
---|
154 | {
|
---|
155 | union f32_f uA;
|
---|
156 |
|
---|
157 | uA.f32 = a;
|
---|
158 | return (int32_t) uA.f;
|
---|
159 |
|
---|
160 | }
|
---|
161 |
|
---|
162 | int_fast64_t subj_f32_to_i64_rx_minMag( float32_t a )
|
---|
163 | {
|
---|
164 | union f32_f uA;
|
---|
165 |
|
---|
166 | uA.f32 = a;
|
---|
167 | return (int64_t) uA.f;
|
---|
168 |
|
---|
169 | }
|
---|
170 |
|
---|
171 | float32_t subj_f32_add( float32_t a, float32_t b )
|
---|
172 | {
|
---|
173 | union f32_f uA, uB, uZ;
|
---|
174 |
|
---|
175 | uA.f32 = a;
|
---|
176 | uB.f32 = b;
|
---|
177 | uZ.f = uA.f + uB.f;
|
---|
178 | return uZ.f32;
|
---|
179 |
|
---|
180 | }
|
---|
181 |
|
---|
182 | float32_t subj_f32_sub( float32_t a, float32_t b )
|
---|
183 | {
|
---|
184 | union f32_f uA, uB, uZ;
|
---|
185 |
|
---|
186 | uA.f32 = a;
|
---|
187 | uB.f32 = b;
|
---|
188 | uZ.f = uA.f - uB.f;
|
---|
189 | return uZ.f32;
|
---|
190 |
|
---|
191 | }
|
---|
192 |
|
---|
193 | float32_t subj_f32_mul( float32_t a, float32_t b )
|
---|
194 | {
|
---|
195 | union f32_f uA, uB, uZ;
|
---|
196 |
|
---|
197 | uA.f32 = a;
|
---|
198 | uB.f32 = b;
|
---|
199 | uZ.f = uA.f * uB.f;
|
---|
200 | return uZ.f32;
|
---|
201 |
|
---|
202 | }
|
---|
203 |
|
---|
204 | #ifdef __STDC_VERSION__
|
---|
205 | #if 199901L <= __STDC_VERSION__
|
---|
206 |
|
---|
207 | float32_t subj_f32_mulAdd( float32_t a, float32_t b, float32_t c )
|
---|
208 | {
|
---|
209 | union f32_f uA, uB, uC, uZ;
|
---|
210 |
|
---|
211 | uA.f32 = a;
|
---|
212 | uB.f32 = b;
|
---|
213 | uC.f32 = c;
|
---|
214 | uZ.f = fmaf( uA.f, uB.f, uC.f );
|
---|
215 | return uZ.f32;
|
---|
216 |
|
---|
217 | }
|
---|
218 |
|
---|
219 | #endif
|
---|
220 | #endif
|
---|
221 |
|
---|
222 | float32_t subj_f32_div( float32_t a, float32_t b )
|
---|
223 | {
|
---|
224 | union f32_f uA, uB, uZ;
|
---|
225 |
|
---|
226 | uA.f32 = a;
|
---|
227 | uB.f32 = b;
|
---|
228 | uZ.f = uA.f / uB.f;
|
---|
229 | return uZ.f32;
|
---|
230 |
|
---|
231 | }
|
---|
232 |
|
---|
233 | #ifdef __STDC_VERSION__
|
---|
234 | #if 199901L <= __STDC_VERSION__
|
---|
235 |
|
---|
236 | float32_t subj_f32_sqrt( float32_t a )
|
---|
237 | {
|
---|
238 | union f32_f uA, uZ;
|
---|
239 |
|
---|
240 | uA.f32 = a;
|
---|
241 | uZ.f = sqrtf( uA.f );
|
---|
242 | return uZ.f32;
|
---|
243 |
|
---|
244 | }
|
---|
245 |
|
---|
246 | #endif
|
---|
247 | #endif
|
---|
248 |
|
---|
249 | bool subj_f32_eq( float32_t a, float32_t b )
|
---|
250 | {
|
---|
251 | union f32_f uA, uB;
|
---|
252 |
|
---|
253 | uA.f32 = a;
|
---|
254 | uB.f32 = b;
|
---|
255 | return (uA.f == uB.f);
|
---|
256 |
|
---|
257 | }
|
---|
258 |
|
---|
259 | bool subj_f32_le( float32_t a, float32_t b )
|
---|
260 | {
|
---|
261 | union f32_f uA, uB;
|
---|
262 |
|
---|
263 | uA.f32 = a;
|
---|
264 | uB.f32 = b;
|
---|
265 | return (uA.f <= uB.f);
|
---|
266 |
|
---|
267 | }
|
---|
268 |
|
---|
269 | bool subj_f32_lt( float32_t a, float32_t b )
|
---|
270 | {
|
---|
271 | union f32_f uA, uB;
|
---|
272 |
|
---|
273 | uA.f32 = a;
|
---|
274 | uB.f32 = b;
|
---|
275 | return (uA.f < uB.f);
|
---|
276 |
|
---|
277 | }
|
---|
278 |
|
---|
279 | /*----------------------------------------------------------------------------
|
---|
280 | *----------------------------------------------------------------------------*/
|
---|
281 |
|
---|
282 | #ifdef FLOAT64
|
---|
283 |
|
---|
284 | union f64_d { float64_t f64; double d; };
|
---|
285 |
|
---|
286 | float64_t subj_ui32_to_f64( uint32_t a )
|
---|
287 | {
|
---|
288 | union f64_d uZ;
|
---|
289 |
|
---|
290 | uZ.d = a;
|
---|
291 | return uZ.f64;
|
---|
292 |
|
---|
293 | }
|
---|
294 |
|
---|
295 | float64_t subj_ui64_to_f64( uint64_t a )
|
---|
296 | {
|
---|
297 | union f64_d uZ;
|
---|
298 |
|
---|
299 | uZ.d = a;
|
---|
300 | return uZ.f64;
|
---|
301 |
|
---|
302 | }
|
---|
303 |
|
---|
304 | float64_t subj_i32_to_f64( int32_t a )
|
---|
305 | {
|
---|
306 | union f64_d uZ;
|
---|
307 |
|
---|
308 | uZ.d = a;
|
---|
309 | return uZ.f64;
|
---|
310 |
|
---|
311 | }
|
---|
312 |
|
---|
313 | float64_t subj_i64_to_f64( int64_t a )
|
---|
314 | {
|
---|
315 | union f64_d uZ;
|
---|
316 |
|
---|
317 | uZ.d = a;
|
---|
318 | return uZ.f64;
|
---|
319 |
|
---|
320 | }
|
---|
321 |
|
---|
322 | float64_t subj_f32_to_f64( float32_t a )
|
---|
323 | {
|
---|
324 | union f32_f uA;
|
---|
325 | union f64_d uZ;
|
---|
326 |
|
---|
327 | uA.f32 = a;
|
---|
328 | uZ.d = uA.f;
|
---|
329 | return uZ.f64;
|
---|
330 |
|
---|
331 | }
|
---|
332 |
|
---|
333 | uint_fast32_t subj_f64_to_ui32_rx_minMag( float64_t a )
|
---|
334 | {
|
---|
335 | union f64_d uA;
|
---|
336 |
|
---|
337 | uA.f64 = a;
|
---|
338 | return (uint32_t) uA.d;
|
---|
339 |
|
---|
340 | }
|
---|
341 |
|
---|
342 | uint_fast64_t subj_f64_to_ui64_rx_minMag( float64_t a )
|
---|
343 | {
|
---|
344 | union f64_d uA;
|
---|
345 |
|
---|
346 | uA.f64 = a;
|
---|
347 | return (uint64_t) uA.d;
|
---|
348 |
|
---|
349 | }
|
---|
350 |
|
---|
351 | int_fast32_t subj_f64_to_i32_rx_minMag( float64_t a )
|
---|
352 | {
|
---|
353 | union f64_d uA;
|
---|
354 |
|
---|
355 | uA.f64 = a;
|
---|
356 | return (int32_t) uA.d;
|
---|
357 |
|
---|
358 | }
|
---|
359 |
|
---|
360 | int_fast64_t subj_f64_to_i64_rx_minMag( float64_t a )
|
---|
361 | {
|
---|
362 | union f64_d uA;
|
---|
363 |
|
---|
364 | uA.f64 = a;
|
---|
365 | return (int64_t) uA.d;
|
---|
366 |
|
---|
367 | }
|
---|
368 |
|
---|
369 | float32_t subj_f64_to_f32( float64_t a )
|
---|
370 | {
|
---|
371 | union f64_d uA;
|
---|
372 | union f32_f uZ;
|
---|
373 |
|
---|
374 | uA.f64 = a;
|
---|
375 | uZ.f = uA.d;
|
---|
376 | return uZ.f32;
|
---|
377 |
|
---|
378 | }
|
---|
379 |
|
---|
380 | float64_t subj_f64_add( float64_t a, float64_t b )
|
---|
381 | {
|
---|
382 | union f64_d uA, uB, uZ;
|
---|
383 |
|
---|
384 | uA.f64 = a;
|
---|
385 | uB.f64 = b;
|
---|
386 | uZ.d = uA.d + uB.d;
|
---|
387 | return uZ.f64;
|
---|
388 |
|
---|
389 | }
|
---|
390 |
|
---|
391 | float64_t subj_f64_sub( float64_t a, float64_t b )
|
---|
392 | {
|
---|
393 | union f64_d uA, uB, uZ;
|
---|
394 |
|
---|
395 | uA.f64 = a;
|
---|
396 | uB.f64 = b;
|
---|
397 | uZ.d = uA.d - uB.d;
|
---|
398 | return uZ.f64;
|
---|
399 |
|
---|
400 | }
|
---|
401 |
|
---|
402 | float64_t subj_f64_mul( float64_t a, float64_t b )
|
---|
403 | {
|
---|
404 | union f64_d uA, uB, uZ;
|
---|
405 |
|
---|
406 | uA.f64 = a;
|
---|
407 | uB.f64 = b;
|
---|
408 | uZ.d = uA.d * uB.d;
|
---|
409 | return uZ.f64;
|
---|
410 |
|
---|
411 | }
|
---|
412 |
|
---|
413 | #ifdef __STDC_VERSION__
|
---|
414 | #if 199901L <= __STDC_VERSION__
|
---|
415 |
|
---|
416 | float64_t subj_f64_mulAdd( float64_t a, float64_t b, float64_t c )
|
---|
417 | {
|
---|
418 | union f64_d uA, uB, uC, uZ;
|
---|
419 |
|
---|
420 | uA.f64 = a;
|
---|
421 | uB.f64 = b;
|
---|
422 | uC.f64 = c;
|
---|
423 | uZ.d = fma( uA.d, uB.d, uC.d );
|
---|
424 | return uZ.f64;
|
---|
425 |
|
---|
426 | }
|
---|
427 |
|
---|
428 | #endif
|
---|
429 | #endif
|
---|
430 |
|
---|
431 | float64_t subj_f64_div( float64_t a, float64_t b )
|
---|
432 | {
|
---|
433 | union f64_d uA, uB, uZ;
|
---|
434 |
|
---|
435 | uA.f64 = a;
|
---|
436 | uB.f64 = b;
|
---|
437 | uZ.d = uA.d / uB.d;
|
---|
438 | return uZ.f64;
|
---|
439 |
|
---|
440 | }
|
---|
441 |
|
---|
442 | float64_t subj_f64_sqrt( float64_t a )
|
---|
443 | {
|
---|
444 | union f64_d uA, uZ;
|
---|
445 |
|
---|
446 | uA.f64 = a;
|
---|
447 | uZ.d = sqrt( uA.d );
|
---|
448 | return uZ.f64;
|
---|
449 |
|
---|
450 | }
|
---|
451 |
|
---|
452 | bool subj_f64_eq( float64_t a, float64_t b )
|
---|
453 | {
|
---|
454 | union f64_d uA, uB;
|
---|
455 |
|
---|
456 | uA.f64 = a;
|
---|
457 | uB.f64 = b;
|
---|
458 | return (uA.d == uB.d);
|
---|
459 |
|
---|
460 | }
|
---|
461 |
|
---|
462 | bool subj_f64_le( float64_t a, float64_t b )
|
---|
463 | {
|
---|
464 | union f64_d uA, uB;
|
---|
465 |
|
---|
466 | uA.f64 = a;
|
---|
467 | uB.f64 = b;
|
---|
468 | return (uA.d <= uB.d);
|
---|
469 |
|
---|
470 | }
|
---|
471 |
|
---|
472 | bool subj_f64_lt( float64_t a, float64_t b )
|
---|
473 | {
|
---|
474 | union f64_d uA, uB;
|
---|
475 |
|
---|
476 | uA.f64 = a;
|
---|
477 | uB.f64 = b;
|
---|
478 | return (uA.d < uB.d);
|
---|
479 |
|
---|
480 | }
|
---|
481 |
|
---|
482 | #endif
|
---|
483 |
|
---|
484 | /*----------------------------------------------------------------------------
|
---|
485 | *----------------------------------------------------------------------------*/
|
---|
486 |
|
---|
487 | #if defined EXTFLOAT80 && defined LONG_DOUBLE_IS_EXTFLOAT80
|
---|
488 |
|
---|
489 | void subj_ui32_to_extF80M( uint32_t a, extFloat80_t *zPtr )
|
---|
490 | {
|
---|
491 |
|
---|
492 | *((long double *) zPtr) = a;
|
---|
493 |
|
---|
494 | }
|
---|
495 |
|
---|
496 | void subj_ui64_to_extF80M( uint64_t a, extFloat80_t *zPtr )
|
---|
497 | {
|
---|
498 |
|
---|
499 | *((long double *) zPtr) = a;
|
---|
500 |
|
---|
501 | }
|
---|
502 |
|
---|
503 | void subj_i32_to_extF80M( int32_t a, extFloat80_t *zPtr )
|
---|
504 | {
|
---|
505 |
|
---|
506 | *((long double *) zPtr) = a;
|
---|
507 |
|
---|
508 | }
|
---|
509 |
|
---|
510 | void subj_i64_to_extF80M( int64_t a, extFloat80_t *zPtr )
|
---|
511 | {
|
---|
512 |
|
---|
513 | *((long double *) zPtr) = a;
|
---|
514 |
|
---|
515 | }
|
---|
516 |
|
---|
517 | void subj_f32_to_extF80M( float32_t a, extFloat80_t *zPtr )
|
---|
518 | {
|
---|
519 | union f32_f uA;
|
---|
520 |
|
---|
521 | uA.f32 = a;
|
---|
522 | *((long double *) zPtr) = uA.f;
|
---|
523 |
|
---|
524 | }
|
---|
525 |
|
---|
526 | #ifdef FLOAT64
|
---|
527 |
|
---|
528 | void subj_f64_to_extF80M( float64_t a, extFloat80_t *zPtr )
|
---|
529 | {
|
---|
530 | union f64_d uA;
|
---|
531 |
|
---|
532 | uA.f64 = a;
|
---|
533 | *((long double *) zPtr) = uA.d;
|
---|
534 |
|
---|
535 | }
|
---|
536 |
|
---|
537 | #endif
|
---|
538 |
|
---|
539 | uint_fast32_t subj_extF80M_to_ui32_rx_minMag( const extFloat80_t *aPtr )
|
---|
540 | {
|
---|
541 |
|
---|
542 | return *((const long double *) aPtr);
|
---|
543 |
|
---|
544 | }
|
---|
545 |
|
---|
546 | uint_fast64_t subj_extF80M_to_ui64_rx_minMag( const extFloat80_t *aPtr )
|
---|
547 | {
|
---|
548 |
|
---|
549 | return *((const long double *) aPtr);
|
---|
550 |
|
---|
551 | }
|
---|
552 |
|
---|
553 | int_fast32_t subj_extF80M_to_i32_rx_minMag( const extFloat80_t *aPtr )
|
---|
554 | {
|
---|
555 |
|
---|
556 | return *((const long double *) aPtr);
|
---|
557 |
|
---|
558 | }
|
---|
559 |
|
---|
560 | int_fast64_t subj_extF80M_to_i64_rx_minMag( const extFloat80_t *aPtr )
|
---|
561 | {
|
---|
562 |
|
---|
563 | return *((const long double *) aPtr);
|
---|
564 |
|
---|
565 | }
|
---|
566 |
|
---|
567 | float32_t subj_extF80M_to_f32( const extFloat80_t *aPtr )
|
---|
568 | {
|
---|
569 | union f32_f uZ;
|
---|
570 |
|
---|
571 | uZ.f = *((const long double *) aPtr);
|
---|
572 | return uZ.f32;
|
---|
573 |
|
---|
574 | }
|
---|
575 |
|
---|
576 | #ifdef FLOAT64
|
---|
577 |
|
---|
578 | float64_t subj_extF80M_to_f64( const extFloat80_t *aPtr )
|
---|
579 | {
|
---|
580 | union f64_d uZ;
|
---|
581 |
|
---|
582 | uZ.d = *((const long double *) aPtr);
|
---|
583 | return uZ.f64;
|
---|
584 |
|
---|
585 | }
|
---|
586 |
|
---|
587 | #endif
|
---|
588 |
|
---|
589 | void
|
---|
590 | subj_extF80M_add(
|
---|
591 | const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
|
---|
592 | {
|
---|
593 |
|
---|
594 | *((long double *) zPtr) =
|
---|
595 | *((const long double *) aPtr) + *((const long double *) bPtr);
|
---|
596 |
|
---|
597 | }
|
---|
598 |
|
---|
599 | void
|
---|
600 | subj_extF80M_sub(
|
---|
601 | const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
|
---|
602 | {
|
---|
603 |
|
---|
604 | *((long double *) zPtr) =
|
---|
605 | *((const long double *) aPtr) - *((const long double *) bPtr);
|
---|
606 |
|
---|
607 | }
|
---|
608 |
|
---|
609 | void
|
---|
610 | subj_extF80M_mul(
|
---|
611 | const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
|
---|
612 | {
|
---|
613 |
|
---|
614 | *((long double *) zPtr) =
|
---|
615 | *((const long double *) aPtr) * *((const long double *) bPtr);
|
---|
616 |
|
---|
617 | }
|
---|
618 |
|
---|
619 | void
|
---|
620 | subj_extF80M_div(
|
---|
621 | const extFloat80_t *aPtr, const extFloat80_t *bPtr, extFloat80_t *zPtr )
|
---|
622 | {
|
---|
623 |
|
---|
624 | *((long double *) zPtr) =
|
---|
625 | *((const long double *) aPtr) / *((const long double *) bPtr);
|
---|
626 |
|
---|
627 | }
|
---|
628 |
|
---|
629 | bool subj_extF80M_eq( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
|
---|
630 | {
|
---|
631 |
|
---|
632 | return (*((const long double *) aPtr) == *((const long double *) bPtr));
|
---|
633 |
|
---|
634 | }
|
---|
635 |
|
---|
636 | bool subj_extF80M_le( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
|
---|
637 | {
|
---|
638 |
|
---|
639 | return (*((const long double *) aPtr) <= *((const long double *) bPtr));
|
---|
640 |
|
---|
641 | }
|
---|
642 |
|
---|
643 | bool subj_extF80M_lt( const extFloat80_t *aPtr, const extFloat80_t *bPtr )
|
---|
644 | {
|
---|
645 |
|
---|
646 | return (*((const long double *) aPtr) < *((const long double *) bPtr));
|
---|
647 |
|
---|
648 | }
|
---|
649 |
|
---|
650 | #endif
|
---|
651 |
|
---|
652 | /*----------------------------------------------------------------------------
|
---|
653 | *----------------------------------------------------------------------------*/
|
---|
654 |
|
---|
655 | #if defined FLOAT128 && defined LONG_DOUBLE_IS_FLOAT128
|
---|
656 |
|
---|
657 | void subj_ui32_to_f128M( uint32_t a, float128_t *zPtr )
|
---|
658 | {
|
---|
659 |
|
---|
660 | *((long double *) zPtr) = a;
|
---|
661 |
|
---|
662 | }
|
---|
663 |
|
---|
664 | void subj_ui64_to_f128M( uint64_t a, float128_t *zPtr )
|
---|
665 | {
|
---|
666 |
|
---|
667 | *((long double *) zPtr) = a;
|
---|
668 |
|
---|
669 | }
|
---|
670 |
|
---|
671 | void subj_i32_to_f128M( int32_t a, float128_t *zPtr )
|
---|
672 | {
|
---|
673 |
|
---|
674 | *((long double *) zPtr) = a;
|
---|
675 |
|
---|
676 | }
|
---|
677 |
|
---|
678 | void subj_i64_to_f128M( int64_t a, float128_t *zPtr )
|
---|
679 | {
|
---|
680 |
|
---|
681 | *((long double *) zPtr) = a;
|
---|
682 |
|
---|
683 | }
|
---|
684 |
|
---|
685 | void subj_f32_to_f128M( float32_t a, float128_t *zPtr )
|
---|
686 | {
|
---|
687 | union f32_f uA;
|
---|
688 |
|
---|
689 | uA.f32 = a;
|
---|
690 | *((long double *) zPtr) = uA.f;
|
---|
691 |
|
---|
692 | }
|
---|
693 |
|
---|
694 | #ifdef FLOAT64
|
---|
695 |
|
---|
696 | void subj_f64_to_f128M( float64_t a, float128_t *zPtr )
|
---|
697 | {
|
---|
698 | union f64_d uA;
|
---|
699 |
|
---|
700 | uA.f64 = a;
|
---|
701 | *((long double *) zPtr) = uA.d;
|
---|
702 |
|
---|
703 | }
|
---|
704 |
|
---|
705 | #endif
|
---|
706 |
|
---|
707 | uint_fast32_t subj_f128M_to_ui32_rx_minMag( const float128_t *aPtr )
|
---|
708 | {
|
---|
709 |
|
---|
710 | return *((const long double *) aPtr);
|
---|
711 |
|
---|
712 | }
|
---|
713 |
|
---|
714 | uint_fast64_t subj_f128M_to_ui64_rx_minMag( const float128_t *aPtr )
|
---|
715 | {
|
---|
716 |
|
---|
717 | return *((const long double *) aPtr);
|
---|
718 |
|
---|
719 | }
|
---|
720 |
|
---|
721 | int_fast32_t subj_f128M_to_i32_rx_minMag( const float128_t *aPtr )
|
---|
722 | {
|
---|
723 |
|
---|
724 | return *((const long double *) aPtr);
|
---|
725 |
|
---|
726 | }
|
---|
727 |
|
---|
728 | int_fast64_t subj_f128M_to_i64_rx_minMag( const float128_t *aPtr )
|
---|
729 | {
|
---|
730 |
|
---|
731 | return *((const long double *) aPtr);
|
---|
732 |
|
---|
733 | }
|
---|
734 |
|
---|
735 | float32_t subj_f128M_to_f32( const float128_t *aPtr )
|
---|
736 | {
|
---|
737 | union f32_f uZ;
|
---|
738 |
|
---|
739 | uZ.f = *((const long double *) aPtr);
|
---|
740 | return uZ.f32;
|
---|
741 |
|
---|
742 | }
|
---|
743 |
|
---|
744 | #ifdef FLOAT64
|
---|
745 |
|
---|
746 | float64_t subj_f128M_to_f64( const float128_t *aPtr )
|
---|
747 | {
|
---|
748 | union f64_d uZ;
|
---|
749 |
|
---|
750 | uZ.d = *((const long double *) aPtr);
|
---|
751 | return uZ.f64;
|
---|
752 |
|
---|
753 | }
|
---|
754 |
|
---|
755 | #endif
|
---|
756 |
|
---|
757 | void
|
---|
758 | subj_f128M_add(
|
---|
759 | const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
|
---|
760 | {
|
---|
761 |
|
---|
762 | *((long double *) zPtr) =
|
---|
763 | *((const long double *) aPtr) + *((const long double *) bPtr);
|
---|
764 |
|
---|
765 | }
|
---|
766 |
|
---|
767 | void
|
---|
768 | subj_f128M_sub(
|
---|
769 | const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
|
---|
770 | {
|
---|
771 |
|
---|
772 | *((long double *) zPtr) =
|
---|
773 | *((const long double *) aPtr) - *((const long double *) bPtr);
|
---|
774 |
|
---|
775 | }
|
---|
776 |
|
---|
777 | void
|
---|
778 | subj_f128M_mul(
|
---|
779 | const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
|
---|
780 | {
|
---|
781 |
|
---|
782 | *((long double *) zPtr) =
|
---|
783 | *((const long double *) aPtr) * *((const long double *) bPtr);
|
---|
784 |
|
---|
785 | }
|
---|
786 |
|
---|
787 | #ifdef __STDC_VERSION__
|
---|
788 | #if 199901L <= __STDC_VERSION__
|
---|
789 |
|
---|
790 | void
|
---|
791 | subj_f128M_mulAdd(
|
---|
792 | const float128_t *aPtr,
|
---|
793 | const float128_t *bPtr,
|
---|
794 | const float128_t *cPtr,
|
---|
795 | float128_t *zPtr
|
---|
796 | )
|
---|
797 | {
|
---|
798 |
|
---|
799 | *((long double *) zPtr) =
|
---|
800 | fmal(
|
---|
801 | *((const long double *) aPtr),
|
---|
802 | *((const long double *) bPtr),
|
---|
803 | *((const long double *) cPtr)
|
---|
804 | );
|
---|
805 |
|
---|
806 | }
|
---|
807 |
|
---|
808 | #endif
|
---|
809 | #endif
|
---|
810 |
|
---|
811 | void
|
---|
812 | subj_f128M_div(
|
---|
813 | const float128_t *aPtr, const float128_t *bPtr, float128_t *zPtr )
|
---|
814 | {
|
---|
815 |
|
---|
816 | *((long double *) zPtr) =
|
---|
817 | *((const long double *) aPtr) / *((const long double *) bPtr);
|
---|
818 |
|
---|
819 | }
|
---|
820 |
|
---|
821 | #ifdef __STDC_VERSION__
|
---|
822 | #if 199901L <= __STDC_VERSION__
|
---|
823 |
|
---|
824 | void subj_f128M_sqrt( const float128_t *aPtr, float128_t *zPtr )
|
---|
825 | {
|
---|
826 |
|
---|
827 | *((long double *) zPtr) = sqrtl( *((const long double *) aPtr) );
|
---|
828 |
|
---|
829 | }
|
---|
830 |
|
---|
831 | #endif
|
---|
832 | #endif
|
---|
833 |
|
---|
834 | bool subj_f128M_eq( const float128_t *aPtr, const float128_t *bPtr )
|
---|
835 | {
|
---|
836 |
|
---|
837 | return (*((const long double *) aPtr) == *((const long double *) bPtr));
|
---|
838 |
|
---|
839 | }
|
---|
840 |
|
---|
841 | bool subj_f128M_le( const float128_t *aPtr, const float128_t *bPtr )
|
---|
842 | {
|
---|
843 |
|
---|
844 | return (*((const long double *) aPtr) <= *((const long double *) bPtr));
|
---|
845 |
|
---|
846 | }
|
---|
847 |
|
---|
848 | bool subj_f128M_lt( const float128_t *aPtr, const float128_t *bPtr )
|
---|
849 | {
|
---|
850 |
|
---|
851 | return (*((const long double *) aPtr) < *((const long double *) bPtr));
|
---|
852 |
|
---|
853 | }
|
---|
854 |
|
---|
855 | #endif
|
---|
856 |
|
---|