Module Name: src Committed By: isaki Date: Sun Jan 15 11:56:11 UTC 2017
Modified Files: src/sys/arch/m68k/fpe: fpu_exp.c Log Message: exp(>11356) is +inf even if extended precision. exp(<-11401) is 0 even if extended precision. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/m68k/fpe/fpu_exp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/m68k/fpe/fpu_exp.c diff -u src/sys/arch/m68k/fpe/fpu_exp.c:1.10 src/sys/arch/m68k/fpe/fpu_exp.c:1.11 --- src/sys/arch/m68k/fpe/fpu_exp.c:1.10 Wed Dec 7 11:27:18 2016 +++ src/sys/arch/m68k/fpe/fpu_exp.c Sun Jan 15 11:56:11 2017 @@ -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 @@ struct fpn * 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 @@ fpu_etox(struct fpemu *fe) 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 @@ fpu_etox(struct fpemu *fe) 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;