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_numtest.c] - Diff between revs 148 and 158

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

Rev 148 Rev 158
 
 
/* @(#)z_numtestf.c 1.0 98/08/13 */
/* @(#)z_numtestf.c 1.0 98/08/13 */
/******************************************************************
/******************************************************************
 * Numtest
 * Numtest
 *
 *
 * Input:
 * Input:
 *   x - pointer to a floating point value
 *   x - pointer to a floating point value
 *
 *
 * Output:
 * Output:
 *   An integer that indicates what kind of number was passed in:
 *   An integer that indicates what kind of number was passed in:
 *     NUM = 3 - a finite value
 *     NUM = 3 - a finite value
 *     NAN = 2 - not a number
 *     NAN = 2 - not a number
 *     INF = 1 - an infinite value
 *     INF = 1 - an infinite value
 *           0 - zero
 *           0 - zero
 *
 *
 * Description:
 * Description:
 *   This routine returns an integer that indicates the character-
 *   This routine returns an integer that indicates the character-
 *   istics of the number that was passed in.
 *   istics of the number that was passed in.
 *
 *
 *****************************************************************/
 *****************************************************************/
 
 
#include "fdlibm.h"
#include "fdlibm.h"
#include "zmath.h"
#include "zmath.h"
 
 
int
int
_DEFUN (numtestf, (float),
_DEFUN (numtestf, (float),
        float x)
        float x)
{
{
  __int32_t wx;
  __int32_t wx;
  int exp;
  int exp;
 
 
  GET_FLOAT_WORD (wx, x);
  GET_FLOAT_WORD (wx, x);
 
 
  exp = (wx & 0x7f800000) >> 23;
  exp = (wx & 0x7f800000) >> 23;
 
 
  /* Check for a zero input. */
  /* Check for a zero input. */
  if (x == 0.0)
  if (x == 0.0)
    {
    {
      return (0);
      return (0);
    }
    }
 
 
  /* Check for not a number or infinity. */
  /* Check for not a number or infinity. */
  if (exp == 0x7f8)
  if (exp == 0x7f8)
    {
    {
      if(wx & 0x7fffff)
      if(wx & 0x7fffff)
        return (NAN);
        return (NAN);
      else
      else
        return (INF);
        return (INF);
    }
    }
 
 
  /* Otherwise it's a finite value. */
  /* Otherwise it's a finite value. */
  else
  else
    return (NUM);
    return (NUM);
}
}
 
 
#ifdef _DOUBLE_IS_32BITS
#ifdef _DOUBLE_IS_32BITS
 
 
int numtest (double x)
int numtest (double x)
{
{
  return numtestf ((float) x);
  return numtestf ((float) x);
}
}
 
 
#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.