Project

General

Profile

Actions

Bug #1712

closed

Complex#% Raises NoMethodError for #floor

Added by runpaint (Run Paint Run Run) almost 15 years ago. Updated about 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.2dev (2009-07-01 trunk 23924) [i686-linux]
Backport:
[ruby-core:24110]

Description

=begin
1.8's Complex had a modulus operator (%); 1.9's doesn't, and attempts to use it raise a NoMethodError for #floor because it falls back to Numeric#% which needs #floor. Is this omission intentional? If so, could an appropriate NoMethodError be raised instead? If not, I'd appreciate knowing so I can write the specifications.

 >> Complex(13, 44) % Complex(5, 20)
 NoMethodError: undefined method `floor' for ((189/85)-(8/85)*i):Complex
from (irb):3:in `div'
from (irb):3:in `%'
from (irb):3
from /usr/local/bin/irb:12:in `<main>'

=end

Actions #1

Updated by matz (Yukihiro Matsumoto) almost 15 years ago

=begin
Hi,

In message "Re: [ruby-core:24110] [Bug #1712] Complex#% Raises NoMethodError for #floor"
on Thu, 2 Jul 2009 07:06:32 +0900, Run Paint Run Run writes:

|1.8's Complex had a modulus operator (%); 1.9's doesn't, and attempts to use it raise a NoMethodError for #floor because it falls back to Numeric#% which needs #floor. Is this omission intentional? If so, could an appropriate NoMethodError be raised instead? If not, I'd appreciate knowing so I can write the specifications.

I don't think there's natural definition of modulo on complex numbers,
so that we should undefine % method. We might need to do something
for compatibility's sake. Opinion?

						matz.

=end

Actions #2

Updated by tadf (tadayoshi funaba) almost 15 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r23946.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0