Skip to content

Commit 71f60ec

Browse files
committed
Prevent the use of deprecated or internal functions if possible.
The finite() function has been superseded by isfinite(). There is also no need to use scalb(), as the exponent is also an integer value. We can simply use scalbn(). There is also no need to use __isnanf(). The values passed are guaranteed to be of type float, meaning we can safely use the standard isnan().
1 parent 7df63d4 commit 71f60ec

4 files changed

Lines changed: 7 additions & 7 deletions

File tree

bsdsrc/b_exp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,13 @@ double x, c;
152152
c= x - z*(p1+z*(p2+z*(p3+z*(p4+z*p5))));
153153
c = (x*c)/(2.0-c);
154154

155-
return scalb(1.+(hi-(lo - c)), k);
155+
return scalbn(1.+(hi-(lo - c)), k);
156156
}
157157
/* end of x > lntiny */
158158

159159
else
160160
/* exp(-big#) underflows to zero */
161-
if(finite(x)) return(scalb(1.0,-5000));
161+
if(isfinite(x)) return(scalbn(1.0,-5000));
162162

163163
/* exp(-INF) is zero */
164164
else return(0.0);
@@ -167,5 +167,5 @@ double x, c;
167167

168168
else
169169
/* exp(INF) is INF, exp(+big#) overflows to INF */
170-
return( finite(x) ? scalb(1.0,5000) : x);
170+
return( isfinite(x) ? scalbn(1.0,5000) : x);
171171
}

bsdsrc/b_tgamma.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ tgamma(x)
140140
if (x != 0.0)
141141
u.a = one - tiny; /* raise inexact */
142142
return (one/x);
143-
} else if (!finite(x))
143+
} else if (!isfinite(x))
144144
return (x - x); /* x is NaN or -Inf */
145145
else
146146
return (neg_gam(x));

src/e_scalb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ __ieee754_scalb(double x, double fn)
3535
return scalbn(x,fn);
3636
#else
3737
if (isnan(x)||isnan(fn)) return x*fn;
38-
if (!finite(fn)) {
38+
if (!isfinite(fn)) {
3939
if(fn>0.0) return x*fn;
4040
else return x/(-fn);
4141
}

src/e_scalbf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ __ieee754_scalbf(float x, float fn)
3030
#ifdef _SCALB_INT
3131
return scalbnf(x,fn);
3232
#else
33-
if ((__isnanf)(x)||(__isnanf)(fn)) return x*fn;
34-
if (!finitef(fn)) {
33+
if (isnan(x)||isnan(fn)) return x*fn;
34+
if (!isfinite(fn)) {
3535
if(fn>(float)0.0) return x*fn;
3636
else return x/(-fn);
3737
}

0 commit comments

Comments
 (0)