source: trunk/sys/libm/w_scalb.c @ 68

Last change on this file since 68 was 1, checked in by alain, 7 years ago

First import

File size: 1.3 KB
Line 
1
2/* @(#)w_scalb.c 5.1 93/09/24 */
3/*
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 *
7 * Developed at SunPro, a Sun Microsystems, Inc. business.
8 * Permission to use, copy, modify, and distribute this
9 * software is freely granted, provided that this notice
10 * is preserved.
11 * ====================================================
12 */
13
14/*
15 * wrapper scalb(double x, double fn) is provide for
16 * passing various standard test suite. One
17 * should use scalbn() instead.
18 */
19
20#include <libm/fdlibm.h>
21
22#include <errno.h>
23
24#ifdef __STDC__
25#ifdef _SCALB_INT
26        double scalb(double x, int fn)          /* wrapper scalb */
27#else
28        double scalb(double x, double fn)       /* wrapper scalb */
29#endif
30#else
31        double scalb(x,fn)                      /* wrapper scalb */
32#ifdef _SCALB_INT
33        double x; int fn;
34#else
35        double x,fn;
36#endif
37#endif
38{
39#ifdef _IEEE_LIBM
40        return __ieee754_scalb(x,fn);
41#else
42        double z;
43        z = __ieee754_scalb(x,fn);
44        if(_LIB_VERSION == _IEEE_) return z;
45        if(!(finite(z)||isnan(z))&&finite(x)) {
46            return __kernel_standard(x,(double)fn,32); /* scalb overflow */
47        }
48        if(z==0.0&&z!=x) {
49            return __kernel_standard(x,(double)fn,33); /* scalb underflow */
50        } 
51#ifndef _SCALB_INT
52        if(!finite(fn)) errno = ERANGE;
53#endif
54        return z;
55#endif
56}
Note: See TracBrowser for help on using the repository browser.