summaryrefslogtreecommitdiff
path: root/lib/libc/arch/m68k
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2001-09-10 22:37:07 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2001-09-10 22:37:07 +0000
commitf8a2c86989b396f318a87ce7f6c1d95b3c911d42 (patch)
treec27e504d9a498690ad7b4370e07a1c4fa4dc0e9d /lib/libc/arch/m68k
parent539d2fe1b065038867a3a79db8cb2c3267d79cd0 (diff)
Use the LBL frexp() on all platforms with ieee floating point.
Diffstat (limited to 'lib/libc/arch/m68k')
-rw-r--r--lib/libc/arch/m68k/gen/frexp.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/lib/libc/arch/m68k/gen/frexp.c b/lib/libc/arch/m68k/gen/frexp.c
index 0fef1f5b73e..21b0cb426a5 100644
--- a/lib/libc/arch/m68k/gen/frexp.c
+++ b/lib/libc/arch/m68k/gen/frexp.c
@@ -1,6 +1,12 @@
-/*-
- * Copyright (c) 1991 The Regents of the University of California.
- * All rights reserved.
+/* $OpenBSD: frexp.c,v 1.4 2001/09/10 22:37:06 millert Exp $ */
+
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,12 +38,17 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$OpenBSD: frexp.c,v 1.3 1997/07/23 20:55:23 kstailey Exp $";
+static char rcsid[] = "$OpenBSD: frexp.c,v 1.4 2001/09/10 22:37:06 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
-#include <math.h>
+#include <machine/ieee.h>
+/*
+ * Split the given value into a fraction in the range [0.5, 1.0) and
+ * an exponent, such that frac * (2^exp) == value. If value is 0,
+ * return 0.
+ */
double
frexp(value, eptr)
double value;
@@ -45,21 +56,23 @@ frexp(value, eptr)
{
union {
double v;
- struct {
- u_int u_sign : 1;
- u_int u_exp : 11;
- u_int u_mant1 : 20;
- u_int u_mant2 : 32;
- } s;
+ struct ieee_double s;
} u;
if (value) {
+ /*
+ * Fractions in [0.5..1.0) have an exponent of 2^-1.
+ * Leave Inf and NaN alone, however.
+ * WHAT ABOUT DENORMS?
+ */
u.v = value;
- *eptr = u.s.u_exp - 1022;
- u.s.u_exp = 1022;
- return(u.v);
+ if (u.s.dbl_exp != DBL_EXP_INFNAN) {
+ *eptr = u.s.dbl_exp - (DBL_EXP_BIAS - 1);
+ u.s.dbl_exp = DBL_EXP_BIAS - 1;
+ }
+ return (u.v);
} else {
*eptr = 0;
- return((double)0);
+ return ((double)0);
}
}