Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Smith <dannysmith@users.sourceforge.net>2004-03-29 12:22:20 +0400
committerDanny Smith <dannysmith@users.sourceforge.net>2004-03-29 12:22:20 +0400
commit521a0aa9a860a74bbe45cf0422dd11baa0ac3aa8 (patch)
treefbbe38c2acb14c0d54853f2513978127c170abb1 /winsup/mingw/mingwex/math/roundf.c
parent20e0dcfb3ed350d961edb2222adeb608fa2f070b (diff)
* mingwex/math/round.c: Rewrite.
* mingwex/math/roundf.c: Rewrite. * mingwex/math/roundl.c: Rewrite.
Diffstat (limited to 'winsup/mingw/mingwex/math/roundf.c')
-rw-r--r--winsup/mingw/mingwex/math/roundf.c31
1 files changed, 5 insertions, 26 deletions
diff --git a/winsup/mingw/mingwex/math/roundf.c b/winsup/mingw/mingwex/math/roundf.c
index 6ae81bdd8..b50d950a7 100644
--- a/winsup/mingw/mingwex/math/roundf.c
+++ b/winsup/mingw/mingwex/math/roundf.c
@@ -1,29 +1,8 @@
-#include <fenv.h>
+#include <math.h>
float
-roundf (float x) {
- double retval;
- unsigned short saved_cw, _cw;
- __asm__ (
- "fnstcw %0;"
- : "=m" (saved_cw)
- ); /* save control word */
- _cw = ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)
- | (x > 0.0 ? FE_UPWARD : FE_DOWNWARD); /* round away from zero */
- __asm__ (
- "fldcw %0;"
- :
- : "m" (_cw)
- ); /* load the rounding control */
- __asm__ (
- "frndint;"
- : "=t" (retval)
- : "0" (x)
- ); /* do the rounding */
- __asm__ (
- "fldcw %0;"
- :
- : "m" (saved_cw)
- ); /* restore control word */
- return retval;
+roundf (float x)
+{
+ /* Add +/- 0.5 then then round towards zero. */
+ return truncf ( x + (x >= 0.0F ? 0.5F : -0.5F));
}