Back to index

glibc  2.9
e_scalbf.c
Go to the documentation of this file.
00001 /* e_scalbf.c -- float version of e_scalb.c.
00002  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
00003  */
00004 
00005 /*
00006  * ====================================================
00007  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
00008  *
00009  * Developed at SunPro, a Sun Microsystems, Inc. business.
00010  * Permission to use, copy, modify, and distribute this
00011  * software is freely granted, provided that this notice
00012  * is preserved.
00013  * ====================================================
00014  */
00015 
00016 #if defined(LIBM_SCCS) && !defined(lint)
00017 static char rcsid[] = "$NetBSD: e_scalbf.c,v 1.3 1995/05/10 20:46:12 jtc Exp $";
00018 #endif
00019 
00020 #include <fenv.h>
00021 #include <math.h>
00022 #include "math_private.h"
00023 
00024 #ifdef _SCALB_INT
00025 #ifdef __STDC__
00026        float __ieee754_scalbf(float x, int fn)
00027 #else
00028        float __ieee754_scalbf(x,fn)
00029        float x; int fn;
00030 #endif
00031 #else
00032 #ifdef __STDC__
00033        float __ieee754_scalbf(float x, float fn)
00034 #else
00035        float __ieee754_scalbf(x,fn)
00036        float x, fn;
00037 #endif
00038 #endif
00039 {
00040 #ifdef _SCALB_INT
00041        return __scalbnf(x,fn);
00042 #else
00043        if (__isnanf(x)||__isnanf(fn)) return x*fn;
00044        if (!__finitef(fn)) {
00045            if(fn>(float)0.0) return x*fn;
00046            else if (x == 0)
00047              return x;
00048            else if (!__finitef (x))
00049              {
00050 # ifdef FE_INVALID
00051               feraiseexcept (FE_INVALID);
00052 # endif
00053               return __nanf ("");
00054              }
00055            else       return x/(-fn);
00056        }
00057        if (__rintf(fn)!=fn)
00058          {
00059 # ifdef FE_INVALID
00060            feraiseexcept (FE_INVALID);
00061 # endif
00062            return __nanf ("");
00063          }
00064        if ( fn > (float)65000.0) return __scalbnf(x, 65000);
00065        if (-fn > (float)65000.0) return __scalbnf(x,-65000);
00066        return __scalbnf(x,(int)fn);
00067 #endif
00068 }