Project

General

Profile

Bug #5490

Bignum#div(0.0) raises FloatDomainError instead of ZeroDivisionError

Added by brixen (Brian Shirai) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
Backport:
[ruby-core:40429]

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

Associated revisions

Revision 723038b0
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • bignum.c (rb_big_divide): raise ZeroDivisionError if divisor is zero, as well as Fixnum. [ruby-core:40429] [Bug #5490]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 33536
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • bignum.c (rb_big_divide): raise ZeroDivisionError if divisor is zero, as well as Fixnum. [ruby-core:40429] [Bug #5490]

Revision 33536
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • bignum.c (rb_big_divide): raise ZeroDivisionError if divisor is zero, as well as Fixnum. [ruby-core:40429] [Bug #5490]

Revision 33536
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • bignum.c (rb_big_divide): raise ZeroDivisionError if divisor is zero, as well as Fixnum. [ruby-core:40429] [Bug #5490]

Revision 33536
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • bignum.c (rb_big_divide): raise ZeroDivisionError if divisor is zero, as well as Fixnum. [ruby-core:40429] [Bug #5490]

Revision 33536
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • bignum.c (rb_big_divide): raise ZeroDivisionError if divisor is zero, as well as Fixnum. [ruby-core:40429] [Bug #5490]

Revision 33536
Added by nobu (Nobuyoshi Nakada) over 7 years ago

  • bignum.c (rb_big_divide): raise ZeroDivisionError if divisor is zero, as well as Fixnum. [ruby-core:40429] [Bug #5490]

Revision 30d76279
Added by naruse (Yui NARUSE) over 7 years ago

  • bignum.c (): refix of r33536. Don't change behavior of Bignum#/. [ruby-core:40429] [Bug #5490]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 33812
Added by naruse (Yui NARUSE) over 7 years ago

  • bignum.c (): refix of r33536. Don't change behavior of Bignum#/. [ruby-core:40429] [Bug #5490]

Revision 33812
Added by naruse (Yui NARUSE) over 7 years ago

  • bignum.c (): refix of r33536. Don't change behavior of Bignum#/. [ruby-core:40429] [Bug #5490]

Revision 33812
Added by naruse (Yui NARUSE) over 7 years ago

  • bignum.c (): refix of r33536. Don't change behavior of Bignum#/. [ruby-core:40429] [Bug #5490]

Revision 33812
Added by naruse (Yui NARUSE) over 7 years ago

  • bignum.c (): refix of r33536. Don't change behavior of Bignum#/. [ruby-core:40429] [Bug #5490]

Revision 33812
Added by naruse (Yui NARUSE) over 7 years ago

  • bignum.c (): refix of r33536. Don't change behavior of Bignum#/. [ruby-core:40429] [Bug #5490]

Revision 33812
Added by naruse (Yui NARUSE) over 7 years ago

  • bignum.c (): refix of r33536. Don't change behavior of Bignum#/. [ruby-core:40429] [Bug #5490]

History

#1

Updated by nobu (Nobuyoshi Nakada) over 7 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 7 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

Also available in: Atom PDF