From: Robert Klemme Date: 2011-04-07T22:43:52+09:00 Subject: Re: Hash Surprises with Fixnum, #hash, and #eql? On Thu, Apr 7, 2011 at 3:21 PM, Phillip Gawlowski wrote: > On Thu, Apr 7, 2011 at 1:53 PM, Robert Klemme > wrote: >> >> Actually it's Numeric which is correct because not every Complex _is a_ Float! > > Unless you convert from polar form* to Cartesian form: > > Let's take "45e^(j * 44°)": > > 32.37029101523930127102246035055203587038080515238845970760... + > 31.25962667065487789953828347402088034639160866937838052053... i > > From . > > * Which you are much more likely to encounter than the Cartesian form, > considering complex numbers are most useful when dealing with wave > forms. My math is a bit rusty in that area, but I don't think your argument holds: cartesian and polar are just two ways to represent a complex number. But this does not change numeric properties of the class of complex numbers. No matter what representation you use, (0+1i) is neither a real number (what float conceptually models) nor a rational number (what float technically implements). Instead, real and rational numbers are both subsets of complex. If you see inheritance as "is a" relationship then inheritance would be Rational < Real < Complex but not the other way round. Otherwise you cannot use a subclass instance everywhere you were using a superclass instance. Further links: http://en.wikipedia.org/wiki/Rational_number http://en.wikipedia.org/wiki/Real_number http://en.wikipedia.org/wiki/Complex_number Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/