OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libm/] [mathfp/] [sf_ldexp.c] - Diff between revs 148 and 158

Only display areas with differences | Details | Blame | View Log

Rev 148 Rev 158
 
 
/* @(#)z_ldexpf.c 1.0 98/08/13 */
/* @(#)z_ldexpf.c 1.0 98/08/13 */
/******************************************************************
/******************************************************************
 * ldexp
 * ldexp
 *
 *
 * Input:
 * Input:
 *   d - a floating point value
 *   d - a floating point value
 *   e - an exponent value
 *   e - an exponent value
 *
 *
 * Output:
 * Output:
 *   A floating point value f such that f = d * 2 ^ e.
 *   A floating point value f such that f = d * 2 ^ e.
 *
 *
 * Description:
 * Description:
 *   This function creates a floating point number f such that
 *   This function creates a floating point number f such that
 *   f = d * 2 ^ e.
 *   f = d * 2 ^ e.
 *
 *
 *****************************************************************/
 *****************************************************************/
 
 
#include <float.h>
#include <float.h>
#include "fdlibm.h"
#include "fdlibm.h"
#include "zmath.h"
#include "zmath.h"
 
 
#define FLOAT_EXP_OFFS 127
#define FLOAT_EXP_OFFS 127
 
 
float
float
_DEFUN (ldexpf, (float, int),
_DEFUN (ldexpf, (float, int),
        float d _AND
        float d _AND
        int e)
        int e)
{
{
  int exp;
  int exp;
  __int32_t wd;
  __int32_t wd;
 
 
  GET_FLOAT_WORD (wd, d);
  GET_FLOAT_WORD (wd, d);
 
 
  /* Check for special values and then scale d by e. */
  /* Check for special values and then scale d by e. */
  switch (numtestf (wd))
  switch (numtestf (wd))
    {
    {
      case NAN:
      case NAN:
        errno = EDOM;
        errno = EDOM;
        break;
        break;
 
 
      case INF:
      case INF:
        errno = ERANGE;
        errno = ERANGE;
        break;
        break;
 
 
      case 0:
      case 0:
        break;
        break;
 
 
      default:
      default:
        exp = (wd & 0x7f800000) >> 23;
        exp = (wd & 0x7f800000) >> 23;
        exp += e;
        exp += e;
 
 
        if (exp > FLT_MAX_EXP + FLOAT_EXP_OFFS)
        if (exp > FLT_MAX_EXP + FLOAT_EXP_OFFS)
         {
         {
           errno = ERANGE;
           errno = ERANGE;
           d = z_infinity_f.f;
           d = z_infinity_f.f;
         }
         }
        else if (exp < FLT_MIN_EXP + FLOAT_EXP_OFFS)
        else if (exp < FLT_MIN_EXP + FLOAT_EXP_OFFS)
         {
         {
           errno = ERANGE;
           errno = ERANGE;
           d = -z_infinity_f.f;
           d = -z_infinity_f.f;
         }
         }
        else
        else
         {
         {
           wd &= 0x807fffff;
           wd &= 0x807fffff;
           wd |= exp << 23;
           wd |= exp << 23;
           SET_FLOAT_WORD (d, wd);
           SET_FLOAT_WORD (d, wd);
         }
         }
    }
    }
 
 
    return (d);
    return (d);
}
}
 
 
#ifdef _DOUBLE_IS_32BITS
#ifdef _DOUBLE_IS_32BITS
 
 
double ldexp (double x, int e)
double ldexp (double x, int e)
{
{
  return (double) ldexpf ((float) x, e);
  return (double) ldexpf ((float) x, e);
}
}
 
 
#endif /* defined(_DOUBLE_IS_32BITS) */
#endif /* defined(_DOUBLE_IS_32BITS) */
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.