78 lines
2.3 KiB
Text
78 lines
2.3 KiB
Text
$NetBSD: patch-aa,v 1.2 2005/08/02 14:53:25 drochner Exp $
|
|
|
|
--- dbl2mpq.c.orig 1998-11-24 06:06:54.000000000 +0100
|
|
+++ dbl2mpq.c
|
|
@@ -5,7 +5,8 @@
|
|
|
|
#include <float.h>
|
|
#include <gmp.h>
|
|
-#include <ieee754.h>
|
|
+#include <sys/types.h>
|
|
+#include <machine/ieee.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "zelibm.h"
|
|
@@ -14,50 +15,50 @@
|
|
void
|
|
extract_double (mpq_t r, double d)
|
|
{
|
|
- union ieee754_double u;
|
|
+ union ieee_double_u u;
|
|
unsigned int val;
|
|
|
|
/* Make the floating point value available in the broken down form. We
|
|
cannot use casting of pointers and other ugly ways to access the bits.
|
|
Using the union is the only half-way clean method. */
|
|
- u.d = d;
|
|
+ u.dblu_d = d;
|
|
|
|
mpq_init (r);
|
|
|
|
/* Set the high word and the denominator to 1. */
|
|
- val = u.ieee.mantissa0;
|
|
- if (u.ieee.exponent != 0)
|
|
+ val = u.dblu_dbl.dbl_frach;
|
|
+ if (u.dblu_dbl.dbl_exp != 0)
|
|
val |= 1 << (DBL_MANT_DIG - 32 - 1);
|
|
mpq_set_ui (r, val, 1);
|
|
/* Shift in the right position. */
|
|
mpz_mul_2exp (mpq_numref (r), mpq_numref (r), 32);
|
|
/* Add the lower word. */
|
|
- mpz_add_ui (mpq_numref (r), mpq_numref (r), u.ieee.mantissa1);
|
|
+ mpz_add_ui (mpq_numref (r), mpq_numref (r), u.dblu_dbl.dbl_fracl);
|
|
|
|
- if (u.ieee.exponent == 0)
|
|
+ if (u.dblu_dbl.dbl_exp == 0)
|
|
{
|
|
- if (u.ieee.mantissa0 != 0 && u.ieee.mantissa1 != 0)
|
|
+ if (u.dblu_dbl.dbl_frach != 0 && u.dblu_dbl.dbl_fracl != 0)
|
|
{
|
|
/* The number is a denormalized. */
|
|
mpz_mul_2exp (mpq_denref (r), mpq_denref (r),
|
|
-DBL_MIN_EXP + DBL_MANT_DIG + 1);
|
|
}
|
|
}
|
|
- else if (u.ieee.exponent >= IEEE754_DOUBLE_BIAS + DBL_MANT_DIG)
|
|
+ else if (u.dblu_dbl.dbl_exp >= DBL_EXP_BIAS + DBL_MANT_DIG)
|
|
{
|
|
/* We have to multiply the numerator with the exponent. */
|
|
mpz_mul_2exp (mpq_numref (r), mpq_numref (r),
|
|
- (u.ieee.exponent
|
|
- - (IEEE754_DOUBLE_BIAS + DBL_MANT_DIG - 1)));
|
|
+ (u.dblu_dbl.dbl_exp
|
|
+ - (DBL_EXP_BIAS + DBL_MANT_DIG - 1)));
|
|
}
|
|
else
|
|
{
|
|
/* Set denominator to the appropriate power of 2. */
|
|
mpz_mul_2exp (mpq_denref (r), mpq_denref (r),
|
|
- ((IEEE754_DOUBLE_BIAS + DBL_MANT_DIG - 1)
|
|
- - u.ieee.exponent));
|
|
+ ((DBL_EXP_BIAS + DBL_MANT_DIG - 1)
|
|
+ - u.dblu_dbl.dbl_exp));
|
|
}
|
|
|
|
- if (u.ieee.negative)
|
|
+ if (u.dblu_dbl.dbl_sign)
|
|
mpq_neg (r, r);
|
|
}
|