OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [newlib/] [libm/] [common/] [sf_llround.c] - Diff between revs 207 and 345

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

Rev 207 Rev 345
/* lroundf adapted to be llroundf for Newlib, 2009 by Craig Howland.  */
/* lroundf adapted to be llroundf for Newlib, 2009 by Craig Howland.  */
/*
/*
 * ====================================================
 * ====================================================
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
 *
 *
 * Developed at SunPro, a Sun Microsystems, Inc. business.
 * Developed at SunPro, a Sun Microsystems, Inc. business.
 * Permission to use, copy, modify, and distribute this
 * Permission to use, copy, modify, and distribute this
 * software is freely granted, provided that this notice
 * software is freely granted, provided that this notice
 * is preserved.
 * is preserved.
 * ====================================================
 * ====================================================
 */
 */
 
 
#include "fdlibm.h"
#include "fdlibm.h"
 
 
long long int
long long int
llroundf(float x)
llroundf(float x)
{
{
  __int32_t exponent_less_127;
  __int32_t exponent_less_127;
  __uint32_t w;
  __uint32_t w;
  long long int result;
  long long int result;
  __int32_t sign;
  __int32_t sign;
 
 
  GET_FLOAT_WORD (w, x);
  GET_FLOAT_WORD (w, x);
  exponent_less_127 = ((w & 0x7f800000) >> 23) - 127;
  exponent_less_127 = ((w & 0x7f800000) >> 23) - 127;
  sign = (w & 0x80000000) != 0 ? -1 : 1;
  sign = (w & 0x80000000) != 0 ? -1 : 1;
  w &= 0x7fffff;
  w &= 0x7fffff;
  w |= 0x800000;
  w |= 0x800000;
 
 
  if (exponent_less_127 < (int)((8 * sizeof (long long int)) - 1))
  if (exponent_less_127 < (int)((8 * sizeof (long long int)) - 1))
    {
    {
      if (exponent_less_127 < 0)
      if (exponent_less_127 < 0)
        return exponent_less_127 < -1 ? 0 : sign;
        return exponent_less_127 < -1 ? 0 : sign;
      else if (exponent_less_127 >= 23)
      else if (exponent_less_127 >= 23)
        result = (long long int) w << (exponent_less_127 - 23);
        result = (long long int) w << (exponent_less_127 - 23);
      else
      else
        {
        {
          w += 0x400000 >> exponent_less_127;
          w += 0x400000 >> exponent_less_127;
          result = w >> (23 - exponent_less_127);
          result = w >> (23 - exponent_less_127);
        }
        }
    }
    }
  else
  else
      return (long long int) x;
      return (long long int) x;
 
 
  return sign * result;
  return sign * result;
}
}
 
 
#ifdef _DOUBLE_IS_32BITS
#ifdef _DOUBLE_IS_32BITS
 
 
long long int
long long int
llround(double x)
llround(double x)
{
{
        return llroundf((float) x);
        return llroundf((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.