Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/m68k/fpe exp(>11356) is +inf even if extended preci...
details: https://anonhg.NetBSD.org/src/rev/020bc8206612
branches: trunk
changeset: 350652:020bc8206612
user: isaki <isaki%NetBSD.org@localhost>
date: Sun Jan 15 11:56:11 2017 +0000
description:
exp(>11356) is +inf even if extended precision.
exp(<-11401) is 0 even if extended precision.
diffstat:
sys/arch/m68k/fpe/fpu_exp.c | 32 ++++++++++++++++++--------------
1 files changed, 18 insertions(+), 14 deletions(-)
diffs (67 lines):
diff -r bc71e7f02aff -r 020bc8206612 sys/arch/m68k/fpe/fpu_exp.c
--- a/sys/arch/m68k/fpe/fpu_exp.c Sun Jan 15 11:46:21 2017 +0000
+++ b/sys/arch/m68k/fpe/fpu_exp.c Sun Jan 15 11:56:11 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fpu_exp.c,v 1.10 2016/12/07 11:27:18 isaki Exp $ */
+/* $NetBSD: fpu_exp.c,v 1.11 2017/01/15 11:56:11 isaki Exp $ */
/*
* Copyright (c) 1995 Ken Nakata
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fpu_exp.c,v 1.10 2016/12/07 11:27:18 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fpu_exp.c,v 1.11 2017/01/15 11:56:11 isaki Exp $");
#include <machine/ieee.h>
@@ -109,7 +109,7 @@
fpu_etox(struct fpemu *fe)
{
struct fpn x, *fp;
- int j, k;
+ int k;
if (ISNAN(&fe->fe_f2))
return &fe->fe_f2;
@@ -119,6 +119,20 @@
return &fe->fe_f2;
}
+ /*
+ * return inf if x >= 2^14
+ * return +0 if x <= -2^14
+ */
+ if (fe->fe_f2.fp_exp >= 14) {
+ if (fe->fe_f2.fp_sign) {
+ fe->fe_f2.fp_class = FPC_ZERO;
+ fe->fe_f2.fp_sign = 0;
+ } else {
+ fe->fe_f2.fp_class = FPC_INF;
+ }
+ return &fe->fe_f2;
+ }
+
CPYFPN(&x, &fe->fe_f2);
/* k = round(x / ln2) */
@@ -134,17 +148,7 @@
return fp;
}
/* extract k as integer format from fpn format */
- j = FP_LG - fp->fp_exp;
- if (j < 0) {
- if (fp->fp_sign) {
- fp->fp_class = FPC_ZERO; /* k < -2^18 */
- fp->fp_sign = 0;
- } else {
- fp->fp_class = FPC_INF; /* k > 2^18 */
- }
- return fp;
- }
- k = fp->fp_mant[0] >> j;
+ k = fp->fp_mant[0] >> (FP_LG - fp->fp_exp);
if (fp->fp_sign)
k *= -1;
Home |
Main Index |
Thread Index |
Old Index