Back to index

glibc  2.9
e_scalbl.c
Go to the documentation of this file.
00001 /* e_scalbl.c -- long double version of s_scalb.c.
00002  * Conversion to long double by Ulrich Drepper,
00003  * Cygnus Support, drepper@cygnus.com.
00004  */
00005 
00006 /*
00007  * ====================================================
00008  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
00009  *
00010  * Developed at SunPro, a Sun Microsystems, Inc. business.
00011  * Permission to use, copy, modify, and distribute this
00012  * software is freely granted, provided that this notice
00013  * is preserved.
00014  * ====================================================
00015  */
00016 
00017 #if defined(LIBM_SCCS) && !defined(lint)
00018 static char rcsid[] = "$NetBSD: $";
00019 #endif
00020 
00021 /*
00022  * __ieee754_scalbl(x, fn) is provide for
00023  * passing various standard test suite. One
00024  * should use scalbnl() instead.
00025  */
00026 
00027 #include <fenv.h>
00028 #include <math.h>
00029 #include "math_private.h"
00030 
00031 #ifdef _SCALB_INT
00032 #ifdef __STDC__
00033        long double __ieee754_scalbl(long double x, int fn)
00034 #else
00035        long double __ieee754_scalbl(x,fn)
00036        long double x; int fn;
00037 #endif
00038 #else
00039 #ifdef __STDC__
00040        long double __ieee754_scalbl(long double x, long double fn)
00041 #else
00042        long double __ieee754_scalbl(x,fn)
00043        long double x, fn;
00044 #endif
00045 #endif
00046 {
00047 #ifdef _SCALB_INT
00048        return __scalbnl(x,fn);
00049 #else
00050        if (__isnanl(x)||__isnanl(fn)) return x*fn;
00051        if (!__finitel(fn)) {
00052            if(fn>0.0) return x*fn;
00053            else if (x == 0)
00054              return x;
00055            else if (!__finitel (x))
00056              {
00057 # ifdef FE_INVALID
00058               feraiseexcept (FE_INVALID);
00059 # endif
00060               return __nanl ("");
00061              }
00062            else       return x/(-fn);
00063        }
00064        if (__rintl(fn)!=fn)
00065          {
00066 # ifdef FE_INVALID
00067            feraiseexcept (FE_INVALID);
00068 # endif
00069            return __nanl ("");
00070          }
00071        if ( fn > 65000.0) return __scalbnl(x, 65000);
00072        if (-fn > 65000.0) return __scalbnl(x,-65000);
00073        return __scalbnl(x,(int)fn);
00074 #endif
00075 }