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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [newlib-1.18.0/] [newlib/] [libm/] [machine/] [i386/] [f_rint.c] - Blame information for rev 816

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

Line No. Rev Author Line
1 207 jeremybenn
/*
2
 * ====================================================
3
 * x87 FP implementation contributed to Newlib by
4
 * Dave Korn, November 2007.  This file is placed in the
5
 * public domain.  Permission to use, copy, modify, and
6
 * distribute this software is freely granted.
7
 * ====================================================
8
 */
9
 
10
#if defined(__GNUC__) && !defined(_SOFT_FLOAT)
11
 
12
#include <math.h>
13
 
14
/*
15
FUNCTION
16
<<rint>>, <<rintf>>, <<rintl>>---round to integer
17
INDEX
18
        rint
19
INDEX
20
        rintf
21
INDEX
22
        rintl
23
 
24
ANSI_SYNOPSIS
25
        #include <math.h>
26
        double rint(double x);
27
        float rintf(float x);
28
        long double rintl(long double x);
29
 
30
TRAD_SYNOPSIS
31
        ANSI-only.
32
 
33
DESCRIPTION
34
The <<rint>>, <<rintf>> and <<rintl>> functions round <[x]> to an integer value
35
in floating-point format, using the current rounding direction.  They may
36
raise the inexact exception if the result differs in value from the argument.
37
 
38
RETURNS
39
These functions return the rounded integer value of <[x]>.
40
 
41
PORTABILITY
42
<<rint>>, <<rintf>> and <<rintl>> are ANSI.
43
<<rint>> and <<rintf>> are available on all platforms.
44
<<rintl>> is only available on i386 platforms when hardware
45
floating point support is available and when compiling with GCC.
46
 
47
*/
48
 
49
/*
50
 * Fast math version of rint(x)
51
 * Return x rounded to integral value according to the prevailing
52
 * rounding mode.
53
 * Method:
54
 *      Using inline x87 asms.
55
 * Exception:
56
 *      Governed by x87 FPCR.
57
 */
58
 
59
double _f_rint (double x)
60
{
61
  double _result;
62
  asm ("frndint" : "=t" (_result) : "0" (x));
63
  return _result;
64
}
65
 
66
#endif  /* !__GNUC__ || _SOFT_FLOAT */
67
 

powered by: WebSVN 2.1.0

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