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/] [common/] [sf_lround.c] - Blame information for rev 365

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*
2
 * ====================================================
3
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
4
 *
5
 * Developed at SunPro, a Sun Microsystems, Inc. business.
6
 * Permission to use, copy, modify, and distribute this
7
 * software is freely granted, provided that this notice
8
 * is preserved.
9
 * ====================================================
10
 */
11
 
12
#include "fdlibm.h"
13
 
14
#ifdef __STDC__
15
        long int lroundf(float x)
16
#else
17
        long int lroundf(x)
18
        float x;
19
#endif
20
{
21
  __int32_t exponent_less_127;
22
  __uint32_t w;
23
  long int result;
24
  __int32_t sign;
25
 
26
  GET_FLOAT_WORD (w, x);
27
  exponent_less_127 = ((w & 0x7f800000) >> 23) - 127;
28
  sign = (w & 0x80000000) != 0 ? -1 : 1;
29
  w &= 0x7fffff;
30
  w |= 0x800000;
31
 
32
  if (exponent_less_127 < (int)((8 * sizeof (long int)) - 1))
33
    {
34
      if (exponent_less_127 < 0)
35
        return exponent_less_127 < -1 ? 0 : sign;
36
      else if (exponent_less_127 >= 23)
37
        result = (long int) w << (exponent_less_127 - 23);
38
      else
39
        {
40
          w += 0x400000 >> exponent_less_127;
41
          result = w >> (23 - exponent_less_127);
42
        }
43
    }
44
  else
45
      return (long int) x;
46
 
47
  return sign * result;
48
}
49
 
50
#ifdef _DOUBLE_IS_32BITS
51
 
52
#ifdef __STDC__
53
        long int lround(double x)
54
#else
55
        long int lround(x)
56
        double x;
57
#endif
58
{
59
        return (double) lroundf((float) x);
60
}
61
 
62
#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.