summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-08-15 13:12:50 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-08-15 13:12:50 +0000
commit6bd99b8eaea5d59b8104b56ad10dfc92901fc9e7 (patch)
tree5f4f57009bf673806e096e5e74a72d84b113db3c /numeric.c
parent008c120d150916b699a18379c5ca915f9a17697d (diff)
downloadperl-6bd99b8eaea5d59b8104b56ad10dfc92901fc9e7.tar.gz
Also UNICOS is in the general case unable to silently
handle fp overflows. p4raw-id: //depot/perl@11681
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/numeric.c b/numeric.c
index c601943485..f12e9ba2d3 100644
--- a/numeric.c
+++ b/numeric.c
@@ -572,6 +572,7 @@ S_mulexp10(NV value, I32 exponent)
negative = 1;
exponent = -exponent;
}
+
/* Avoid %SYSTEM-F-FLTOVF_F sans VAXC$ESTABLISH.
* In VAX VMS we by default use the D_FLOAT double format,
* and that format does not have *easy* capabilities [1] for
@@ -591,6 +592,20 @@ S_mulexp10(NV value, I32 exponent)
return NV_MAX;
# endif
#endif
+
+ /* In UNICOS and in certain Cray models (such as T90) there is no
+ * IEEE fp, and no way at all from C to catch fp overflows gracefully.
+ * There is something you can do if you are willing to use some
+ * inline assembler: the instruction is called DFI-- but that will
+ * disable *all* floating point interrupts, a little bit too large
+ * a hammer. Therefore we need to catch potential overflows before
+ * it's too late. */
+#if defined(_UNICOS) && defined(NV_MAX_10_EXP)
+ if (!negative &&
+ (log10(value) + exponent) >= NV_MAX_10_EXP)
+ return NV_MAX;
+#endif
+
for (bit = 1; exponent; bit <<= 1) {
if (exponent & bit) {
exponent ^= bit;