AFAIK, one has to be careful ordering complex numbers:

   http://www.physicspost.com/physicsforums/topic.asp-ARCHIVE=&TOPIC_ID=2779.htm


If in doubt, I would #shouldNotImplement #< until we can get a conclusive 
answer.  If you have defined it only for pure real or pure imaginary numbers (a 
little tricky with floating point though), then it clearly is ok; off those 
axes, I _think_ it breaks down.

Bill



-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Ken.Dickey
Sent: Tuesday, August 11, 2009 6:50 PM
To: [email protected]
Subject: [Pharo-project] Complex neurotic

Q: What is the difference between a neurotic and a psychotic?
A: A psychotic really thinks 2+2 = 5
   A neurotic knows 2+2 = 4, but just can't stand it.   ;^)

I really can't stand some of the oddities of Complex numbers in Squeak [Note 
Mantis bug 311 -- http://bugs.squeak.org/view.php?id=3311].

I would find the following to be more rational:

3 asComplex.                        "no change--> (3+0i)"
3 asComplex isNumber.       "no change--> true"
-1 asComplex < 1 asComplex. "--> true"
-4 sqrt.        "--> 2.0i"
-3 ln.  "--> (1.098612288668382+3.141592653589793i)"
((1/2) + 2.1i) sin arcSin. "--> (0.500000000000001+2.1i)"
((((1/2) + 2.1i) sin  arcSin)  roundTo: 0.000001) = ((1/2) + 2.1i). "--> true"
((((1/2) + 2.1i) tanH arcTanH) roundTo: 0.000001) = ((1/2) + 2.1i). "--> true"

Attached is a change set which adds a number of tests for Complex and the 
changes for Complex which allow those tests to pass in Pharo1.0beta update: 
#10413.  Note that Complex becomes a subclass of Magnitude.

I thought it would be useful to post the code first for your thoughts and any 
code cleanups.  As an occasional Smalltalk user, you may wish to correct some 
of my idioms.  Please forgive an old newbie.

Thanks in advance,
-KenD     [[email protected]]

PS:  Yes this is MIT.  I signed and sent in the copyright form..

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to