Cygwin: access: Fix X_OK behaviour for backup operators and admins
[newlib-cygwin.git] / newlib / libm / machine / i386 / f_rint.c
blobe72316f22a8ae61b29347cf42e080cba103ff7fa
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 */
10 #if defined(__GNUC__) && !defined(_SOFT_FLOAT)
12 #include <math.h>
15 FUNCTION
16 <<rint>>, <<rintf>>, <<rintl>>---round to integer
17 INDEX
18 rint
19 INDEX
20 rintf
21 INDEX
22 rintl
24 SYNOPSIS
25 #include <math.h>
26 double rint(double x);
27 float rintf(float x);
28 long double rintl(long double x);
30 DESCRIPTION
31 The <<rint>>, <<rintf>> and <<rintl>> functions round <[x]> to an integer value
32 in floating-point format, using the current rounding direction. They may
33 raise the inexact exception if the result differs in value from the argument.
35 RETURNS
36 These functions return the rounded integer value of <[x]>.
38 PORTABILITY
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
42 floating point support is available and when compiling with GCC.
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.
56 double _f_rint (double x)
58 double _result;
59 asm ("frndint" : "=t" (_result) : "0" (x));
60 return _result;
63 #endif /* !__GNUC__ || _SOFT_FLOAT */