Transcript :
emac$ irb
require ‘complex’
=> truecc = Complex(Float::MAX/2, Float::MAX / 2)
=> Complex(8.98846567431158e+307, 8.98846567431158e+307)cc / cc
=> Complex(NaN, NaN)require ‘cpfixup’
=> truecc / cc
=> Complex(1.0, 0.0)exit
Work Directory: ~ :
emac$
Th source of the fix (in a file called ‘cpfixup.rb’ in my home
directory is
require ‘complex’
class Complex < Numeric
def / (other)
if other.kind_of?(Complex)
magn = other.abs
tmp = Complex.new(other.real/magn , other.image/magn)
self * tmp.conjugate / magn
elsif Complex.generic?(other)
Complex(@real/other, @image/other)
else
x, y = other.coerce(self)
x / y
end
end
end