summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'array.c')
-rw-r--r--array.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/array.c b/array.c
index 9061919..c9bf765 100644
--- a/array.c
+++ b/array.c
@@ -5973,6 +5973,20 @@ rb_ary_sum(int argc, VALUE *argv, VALUE ary)
else
goto not_float;
+ if (isnan(f)) continue;
+ if (isnan(x)) {
+ f = x;
+ continue;
+ }
+ if (isinf(x)) {
+ if (isinf(f) && signbit(x) != signbit(f))
+ f = NAN;
+ else
+ f = x;
+ continue;
+ }
+ if (isinf(f)) continue;
+
t = f + x;
if (fabs(f) >= fabs(x))
c += ((f - t) + x);