Bug #1712
closedComplex#% Raises NoMethodError for #floor
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
Updated by matz (Yukihiro Matsumoto) almost 16 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 redmine@ruby-lang.org 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
Updated by tadf (tadayoshi funaba) almost 16 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
Applied in changeset r23946.
=end