summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/util.c b/util.c
index 576641dbfd..f528cd5203 100644
--- a/util.c
+++ b/util.c
@@ -1500,6 +1500,24 @@ double f;
along = (long)f;
return (unsigned long)along;
}
+# undef BIGDOUBLE
+#endif
+
+#ifndef CASTI32
+I32
+cast_i32(f)
+double f;
+{
+# define BIGDOUBLE 2147483648.0 /* Assume 32 bit int's ! */
+# define BIGNEGDOUBLE (-2147483648.0)
+ if (f >= BIGDOUBLE)
+ return (I32)fmod(f, BIGDOUBLE);
+ if (f <= BIGNEGDOUBLE)
+ return (I32)fmod(f, BIGNEGDOUBLE);
+ return (I32) f;
+}
+# undef BIGDOUBLE
+# undef BIGNEGDOUBLE
#endif
#ifndef HAS_RENAME