This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.0 alpha 5
[perl5.git] / util.c
diff --git a/util.c b/util.c
index 576641d..f528cd5 100644 (file)
--- 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