fix for -Wshadow

This commit is contained in:
chs 2001-11-07 15:45:12 +00:00
parent 22fed3d22d
commit 5f13639b8f
1 changed files with 16 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ldexp.c,v 1.8 1999/08/30 18:28:26 mycroft Exp $ */ /* $NetBSD: ldexp.c,v 1.9 2001/11/07 15:45:12 chs Exp $ */
/*- /*-
* Copyright (c) 1999 The NetBSD Foundation, Inc. * Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -38,7 +38,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: ldexp.c,v 1.8 1999/08/30 18:28:26 mycroft Exp $"); __RCSID("$NetBSD: ldexp.c,v 1.9 2001/11/07 15:45:12 chs Exp $");
#endif /* LIBC_SCCS and not lint */ #endif /* LIBC_SCCS and not lint */
#include <sys/types.h> #include <sys/types.h>
@ -47,12 +47,12 @@ __RCSID("$NetBSD: ldexp.c,v 1.8 1999/08/30 18:28:26 mycroft Exp $");
#include <math.h> #include <math.h>
/* /*
* Multiply the given value by 2^exp. * Multiply the given value by 2^expon.
*/ */
double double
ldexp(val, exp) ldexp(val, expon)
double val; double val;
int exp; int expon;
{ {
register int oldexp, newexp; register int oldexp, newexp;
union { union {
@ -74,17 +74,17 @@ ldexp(val, exp)
* u.v is denormal. We must adjust it so that the exponent * u.v is denormal. We must adjust it so that the exponent
* arithmetic below will work. * arithmetic below will work.
*/ */
if (exp <= DBL_EXP_BIAS) { if (expon <= DBL_EXP_BIAS) {
/* /*
* Optimization: if the scaling can be done in a single * Optimization: if the scaling can be done in a single
* multiply, or underflows, just do it now. * multiply, or underflows, just do it now.
*/ */
if (exp <= -DBL_FRACBITS) { if (expon <= -DBL_FRACBITS) {
errno = ERANGE; errno = ERANGE;
return (0.0); return (0.0);
} }
mul.v = 0.0; mul.v = 0.0;
mul.s.dbl_exp = exp + DBL_EXP_BIAS; mul.s.dbl_exp = expon + DBL_EXP_BIAS;
u.v *= mul.v; u.v *= mul.v;
if (u.v == 0.0) { if (u.v == 0.0) {
errno = ERANGE; errno = ERANGE;
@ -93,14 +93,14 @@ ldexp(val, exp)
return (u.v); return (u.v);
} else { } else {
/* /*
* We know that exp is very large, and therefore the * We know that expon is very large, and therefore the
* result cannot be denormal (though it may be Inf). * result cannot be denormal (though it may be Inf).
* Shift u.v by just enough to make it normal. * Shift u.v by just enough to make it normal.
*/ */
mul.v = 0.0; mul.v = 0.0;
mul.s.dbl_exp = DBL_FRACBITS + DBL_EXP_BIAS; mul.s.dbl_exp = DBL_FRACBITS + DBL_EXP_BIAS;
u.v *= mul.v; u.v *= mul.v;
exp -= DBL_FRACBITS; expon -= DBL_FRACBITS;
oldexp = u.s.dbl_exp; oldexp = u.s.dbl_exp;
} }
} }
@ -109,7 +109,7 @@ ldexp(val, exp)
* u.v is now normalized and oldexp has been adjusted if necessary. * u.v is now normalized and oldexp has been adjusted if necessary.
* Calculate the new exponent and check for underflow and overflow. * Calculate the new exponent and check for underflow and overflow.
*/ */
newexp = oldexp + exp; newexp = oldexp + expon;
if (newexp <= 0) { if (newexp <= 0) {
/* /*
@ -121,17 +121,17 @@ ldexp(val, exp)
return (0.0); return (0.0);
} }
/* /*
* Denormalize the result. We do this with a multiply. If exp * Denormalize the result. We do this with a multiply. If
* is very large, it won't fit in a double, so we have to * expon is very large, it won't fit in a double, so we have to
* adjust the exponent first. This is safe because we know * adjust the exponent first. This is safe because we know
* that u.v is normal at this point. * that u.v is normal at this point.
*/ */
if (exp <= -DBL_EXP_BIAS) { if (expon <= -DBL_EXP_BIAS) {
u.s.dbl_exp = 1; u.s.dbl_exp = 1;
exp += oldexp - 1; expon += oldexp - 1;
} }
mul.v = 0.0; mul.v = 0.0;
mul.s.dbl_exp = exp + DBL_EXP_BIAS; mul.s.dbl_exp = expon + DBL_EXP_BIAS;
u.v *= mul.v; u.v *= mul.v;
return (u.v); return (u.v);
} else if (newexp >= DBL_EXP_INFNAN) { } else if (newexp >= DBL_EXP_INFNAN) {