summaryrefslogtreecommitdiff
path: root/enum.c
diff options
context:
space:
mode:
Diffstat (limited to 'enum.c')
-rw-r--r--enum.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/enum.c b/enum.c
index e57fa5e..04b6c9c 100644
--- a/enum.c
+++ b/enum.c
@@ -3809,6 +3809,25 @@ sum_iter(VALUE i, struct enum_sum_memo *memo)
goto some_value;
}
+ if (isnan(f)) return;
+ if (isnan(x)) {
+ memo->v = i;
+ memo->f = x;
+ return;
+ }
+ if (isinf(x)) {
+ if (isinf(f) && signbit(x) != signbit(f)) {
+ memo->f = NAN;
+ memo->v = DBL2NUM(f);
+ }
+ else {
+ memo->f = x;
+ memo->v = i;
+ }
+ return;
+ }
+ if (isinf(f)) return;
+
t = f + x;
if (fabs(f) >= fabs(x))
c += ((f - t) + x);