Break a loop off to avoid a long loop even if the precision is not enough.
This commit is contained in:
parent
df80140090
commit
5d5a7da8b2
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fpu_exp.c,v 1.6 2013/04/20 03:06:19 isaki Exp $ */
|
||||
/* $NetBSD: fpu_exp.c,v 1.7 2013/04/20 04:38:51 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 Ken Nakata
|
||||
@ -32,10 +32,13 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: fpu_exp.c,v 1.6 2013/04/20 03:06:19 isaki Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: fpu_exp.c,v 1.7 2013/04/20 04:38:51 isaki Exp $");
|
||||
|
||||
#include "fpu_emulate.h"
|
||||
|
||||
/* The number of items to terminate the Taylor expansion */
|
||||
#define MAX_ITEMS (2000)
|
||||
|
||||
/*
|
||||
* fpu_exp.c: defines fpu_etox(), fpu_etoxm1(), fpu_tentox(), and fpu_twotox();
|
||||
*/
|
||||
@ -64,7 +67,7 @@ fpu_etox_taylor(struct fpemu *fe)
|
||||
CPYFPN(&res, r);
|
||||
|
||||
k = 2;
|
||||
for (;; k++) {
|
||||
for (; k < MAX_ITEMS; k++) {
|
||||
/* s1 = s0 * x / k */
|
||||
CPYFPN(&fe->fe_f1, &s0);
|
||||
CPYFPN(&fe->fe_f2, &x);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fpu_hyperb.c,v 1.10 2013/04/19 14:05:12 isaki Exp $ */
|
||||
/* $NetBSD: fpu_hyperb.c,v 1.11 2013/04/20 04:38:51 isaki Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1995 Ken Nakata
|
||||
@ -57,10 +57,13 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: fpu_hyperb.c,v 1.10 2013/04/19 14:05:12 isaki Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: fpu_hyperb.c,v 1.11 2013/04/20 04:38:51 isaki Exp $");
|
||||
|
||||
#include "fpu_emulate.h"
|
||||
|
||||
/* The number of items to terminate the Taylor expansion */
|
||||
#define MAX_ITEMS (2000)
|
||||
|
||||
/*
|
||||
* fpu_hyperb.c: defines the following functions
|
||||
*
|
||||
@ -159,7 +162,7 @@ __fpu_sinhcosh_taylor(struct fpemu *fe, struct fpn *s0, uint32_t f)
|
||||
|
||||
sign = 1; /* sign := (-1)^n */
|
||||
|
||||
for (;;) {
|
||||
for (; f < (2 * MAX_ITEMS); ) {
|
||||
/* (f1 :=) s0 * x^2 */
|
||||
CPYFPN(&fe->fe_f1, s0);
|
||||
CPYFPN(&fe->fe_f2, &x2);
|
||||
|
Loading…
Reference in New Issue
Block a user