From: usa@... Date: 2018-08-27T14:11:23+00:00 Subject: [ruby-core:88692] [Ruby trunk Bug#14926] Different results between Enumerable#sum and #reduce when Float::INFINITY present Issue #14926 has been updated by usa (Usaku NAKAMURA). Backport changed from 2.3: DONTNEED, 2.4: REQUIRED, 2.5: REQUIRED to 2.3: DONTNEED, 2.4: DONE, 2.5: REQUIRED ruby_2_4 r64562 merged revision(s) 64014. ---------------------------------------- Bug #14926: Different results between Enumerable#sum and #reduce when Float::INFINITY present https://bugs.ruby-lang.org/issues/14926#change-73750 * Author: swistak35 (Rafa�� ��asocha) * Status: Closed * Priority: Normal * Assignee: * Target version: * ruby -v: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] * Backport: 2.3: DONTNEED, 2.4: DONE, 2.5: REQUIRED ---------------------------------------- When `Float::INFINITY` is present in array, `Enumerable#sum` and `Enumerable#reduce(0, &:+)` are giving different results. ``` puts [Float::INFINITY].sum puts [Float::INFINITY].reduce(0, &:+) ``` results in ``` NaN Infinity ``` And I would expect both of them to be `Infinity` (meaning: `#sum` is working incorrectly). Checked on `ruby 2.5.1p57` and `ruby 2.4.3p205`, both have the same bug. -- https://bugs.ruby-lang.org/ Unsubscribe: