From: nagachika00@... Date: 2016-06-18T19:49:00+00:00 Subject: [ruby-core:76070] [Ruby trunk Bug#12414] FloatDomainError in infinite Range#include? for certain BigDecimals Issue #12414 has been updated by Tomoyuki Chikanaga. Backport changed from 2.1: REQUIRED, 2.2: DONE, 2.3: REQUIRED to 2.1: REQUIRED, 2.2: DONE, 2.3: DONE ruby_2_3 r55445 merged revision(s) 55123,55129,55130,55133,55136. ---------------------------------------- Bug #12414: FloatDomainError in infinite Range#include? for certain BigDecimals https://bugs.ruby-lang.org/issues/12414#change-59270 * Author: A Nonymous * Status: Closed * Priority: Normal * Assignee: * ruby -v: ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14] * Backport: 2.1: REQUIRED, 2.2: DONE, 2.3: DONE ---------------------------------------- # What I did ~~~ruby require 'bigdecimal' r = 0.04...(Float::INFINITY) n = BigDecimal.new('0.13E0') r.include?(n.to_f) r.include?(n) ~~~ # What I expected ~~~ true true ~~~ # What happens instead ~~~ true FloatDomainError: Infinity from (irb):19:in `to_r' from (irb):19:in `<=>' from (irb):19:in `include?' from (irb):19 from /Users/msiegel/.rvm/rubies/ruby-2.2.3/bin/irb:15:in `
' ~~~ # Workaround To workaround, I am calling `#to_f` on the `BigDecimal` before submitting it to the `Range#include?` Note that this exception only occurs for certain BigDecimal values, not for all. -- https://bugs.ruby-lang.org/ Unsubscribe: