Project

General

Profile

Actions

Bug #12414

closed

FloatDomainError in infinite Range#include? for certain BigDecimals

Added by RubyBugs (A Nonymous) almost 8 years ago. Updated almost 8 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
[ruby-core:75682]

Description

What I did

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 `<main>'

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.


Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #12417: warning: "isfinite" redefined when compiling bigdecimal.c on cygwinClosedshyouhei (Shyouhei Urabe)Actions
Is duplicate of Ruby master - Bug #10109: BigDecimal fail to compare to Float::INFINITYClosedmrkn (Kenta Murata)Actions
Actions #1

Updated by nobu (Nobuyoshi Nakada) almost 8 years ago

  • Status changed from Open to Closed

Applied in changeset r55123.


bigdecimal.c: fix FloatDomainError

  • ext/bigdecimal/bigdecimal.c (GetVpValueWithPrec): consider
    non-finite float values not to raise FloatDomainError.
    [ruby-core:75682] [Bug #12414]

Updated by nobu (Nobuyoshi Nakada) almost 8 years ago

  • Description updated (diff)
  • Backport changed from 2.1: UNKNOWN, 2.2: UNKNOWN, 2.3: UNKNOWN to 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED

Updated by nobu (Nobuyoshi Nakada) almost 8 years ago

  • Subject changed from FloatDomainError in infinite Range#inclyde? for certain BigDecimals to FloatDomainError in infinite Range#include? for certain BigDecimals
Actions #4

Updated by usa (Usaku NAKAMURA) almost 8 years ago

  • Related to Bug #12417: warning: "isfinite" redefined when compiling bigdecimal.c on cygwin added

Updated by usa (Usaku NAKAMURA) almost 8 years ago

  • Backport changed from 2.1: REQUIRED, 2.2: REQUIRED, 2.3: REQUIRED to 2.1: REQUIRED, 2.2: DONE, 2.3: REQUIRED

ruby_2_2 r55354 merged revision(s) 55123,55129,55130,55133,55136.

Updated by nagachika (Tomoyuki Chikanaga) almost 8 years ago

  • 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.

Actions #7

Updated by mrkn (Kenta Murata) over 7 years ago

  • Is duplicate of Bug #10109: BigDecimal fail to compare to Float::INFINITY added
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0