source: trunk/libs/newlib/src/newlib/libm/machine/i386/f_rint.c @ 519

Last change on this file since 519 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.5 KB
Line 
1/*
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/*
15FUNCTION
16<<rint>>, <<rintf>>, <<rintl>>---round to integer
17INDEX
18        rint
19INDEX
20        rintf
21INDEX
22        rintl
23
24SYNOPSIS
25        #include <math.h>
26        double rint(double x);
27        float rintf(float x);
28        long double rintl(long double x);
29
30DESCRIPTION
31The <<rint>>, <<rintf>> and <<rintl>> functions round <[x]> to an integer value
32in floating-point format, using the current rounding direction.  They may
33raise the inexact exception if the result differs in value from the argument.
34
35RETURNS
36These functions return the rounded integer value of <[x]>.
37
38PORTABILITY
39<<rint>>, <<rintf>> and <<rintl>> are ANSI.
40<<rint>> and <<rintf>> are available on all platforms.
41<<rintl>> is only available on i386 platforms when hardware
42floating point support is available and when compiling with GCC.
43
44*/
45
46/*
47 * Fast math version of rint(x)
48 * Return x rounded to integral value according to the prevailing
49 * rounding mode.
50 * Method:
51 *      Using inline x87 asms.
52 * Exception:
53 *      Governed by x87 FPCR.
54 */
55
56double _f_rint (double x)
57{
58  double _result;
59  asm ("frndint" : "=t" (_result) : "0" (x));
60  return _result;
61}
62
63#endif  /* !__GNUC__ || _SOFT_FLOAT */
64
Note: See TracBrowser for help on using the repository browser.