From: jzakiya Date: 2010-06-08T10:25:09+09:00 Subject: Re: Complex numbers contradiction? On Jun 7, 6:59 pm, Andrew Duncan wrote: > As a mathematician, and compiler writer for the last twenty years or so, > I am aware of that. > > Joel VanderWerf wrote: > > Andrew Duncan wrote: > >> But (as I now learn as I delve further into canonical Ruby syntax) it is > >> a "feature" that 5/2 evaluates to 2 and not 2.5. So something of the > >> sort is happening here. > > > Many languages, including C, do integer division that way. > > -- > Posted viahttp://www.ruby-forum.com/. Using Ruby 1.8.7-p249 installed with rvm: I get this: ----------------------------------------- require 'complex' Complex(1,1)**-1 => Complex(0.5, -0.5) 1/Complex(1,1) => Complex(0, -1) ----------------------------------------- But, when I use the 'mathn' lib I get: require 'mathn' Complex(1,1)**-1 => Complex(1/2, -1/2) 1/Complex(1,1) => Complex(1/2, -1/2) ----------------------------------------- So require the mathn library first for 1.8.7 to get correct results. For 1.9.1 and 1.9.2 I also get correct results for both cases straight out of the box.