Bug #5490
closedBignum#div(0.0) raises FloatDomainError instead of ZeroDivisionError
Description
Bignum#div(0.0) raises FloatDomainError. Everything else raises ZeroDivisionError.
This should be fixed in both 1.9.3 and 2.0.0.
sasha:rubinius brian$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
sasha:rubinius brian$ irb
ruby-1.9.2-p290 :001 > 1.div 0.0
ZeroDivisionError: divided by 0
from (irb):1:in div' from (irb):1 from /Users/brian/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in
'
ruby-1.9.2-p290 :002 > 1.1.div 0.0
ZeroDivisionError: divided by 0
from (irb):2:in div' from (irb):2 from /Users/brian/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in
'
ruby-1.9.2-p290 :003 > Rational(1).div 0.0
ZeroDivisionError: divided by 0
from (irb):3:in div' from (irb):3 from /Users/brian/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in
'
ruby-1.9.2-p290 :004 > 0xffff_ffff_ffff_ffff.div 0.0
FloatDomainError: Infinity
from (irb):4:in div' from (irb):4 from /Users/brian/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in
'
Thanks,
Brian
Updated by nobu (Nobuyoshi Nakada) over 13 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r33536.
Brian, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
- bignum.c (rb_big_divide): raise ZeroDivisionError if divisor is
zero, as well as Fixnum. [ruby-core:40429] [Bug #5490]
Updated by brixen (Brian Shirai) over 13 years ago
Is this going to be backported to 1.9? The RubySpecs were changed with a ruby_version_is guard, which would be incorrect if this is considered a bug. If it's not considered a bug, why not?
Thanks,
Brian