summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--numeric.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/numeric.c b/numeric.c
index d2144164cd..1cb24d2273 100644
--- a/numeric.c
+++ b/numeric.c
@@ -766,8 +766,11 @@ S_mulexp10(NV value, I32 exponent)
if (exponent & bit) {
exponent ^= bit;
result *= power;
+ /* Floating point exceptions are supposed to be turned off,
+ * but if we're obviously done, don't risk another iteration.
+ */
+ if (exponent == 0) break;
}
- /* Floating point exceptions are supposed to be turned off. */
power *= power;
}
return negative ? value / result : value * result;