ngspice/src/maths/misc/scalb.c

49 lines
612 B
C
Raw Normal View History

/**********
Copyright 1991 Regents of the University of California. All rights reserved.
**********/
#include <ngspice/ngspice.h>
2008-11-19 20:57:27 +01:00
#ifndef HAVE_SCALBN
double
2008-11-19 20:57:27 +01:00
scalbn(double x, int n)
{
double y, z = 1.0, k = 2.0;
if (n < 0) {
n = -n;
k = 0.5;
}
if (x != 0.0)
for (y = 1.0; n; n >>= 1) {
y *= k;
if (n & 1)
z *= y;
}
return x * z;
}
2008-11-19 20:57:27 +01:00
#else /* HAVE_SCALBN */
int Dummy_Symbol_1;
#endif /* HAVE_SCALBN */
#ifndef HAVE_SCALB
double
scalb(double x, double n)
2008-09-24 00:10:56 +02:00
{
2008-11-19 20:57:27 +01:00
return scalbn(x, (int) n);
2008-09-24 00:10:56 +02:00
}
2008-11-19 20:57:27 +01:00
#else /* HAVE_SCALB */
int Dummy_Symbol_2;
#endif /* HAVE_SCALB */