Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!newsstand.cit.cornell.edu!newstand.syr.edu!news.maxwell.syr.edu!EU.net!uknet!usenet1.news.uk.psi.net!uknet!uknet!bcc.ac.uk!news
From: Channing Walton <cwalton@eleceng.ucl.ac.uk>
Subject: Re: Help needed in understanding isInteger or isFloat etc
Sender: news@ucl.ac.uk (Usenet News System)
Message-ID: <32E89871.5BD4@eleceng.ucl.ac.uk>
Date: Fri, 24 Jan 1997 11:09:37 GMT
Reply-To: cwalton@ee.ucl.ac.uk
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii
References: <32E6380E.30AB@eleceng.ucl.ac.uk> <32E7A233.35BB@isis.star.fedex.com>
Mime-Version: 1.0
X-Mailer: Mozilla 2.0 (Macintosh; I; 68K)
Organization: University College London
Lines: 34

Matt Butler wrote:

>  Here's another idea in addition to implementing Number>>isComplex to
> answer false.
> 
> Add these methods:
> 
> Number>>real
> 
>         ^self
> 
> Number>>imag
> 
>         ^0
> 
> Complex>>+ aNumber
>         "Answer the result of adding
>          the receiver to aNumber."
>          ^Complex real: (real+aNumber real) imag: (imag + aNumber imag)
> 
>  I don't know if this is valid complex number mathematics, but the idea
> is that for a non-complex number, the real method just returns self and
> the imag method returns zero, so you don't need to check the type when
> adding.  That is, in the + aNumber method, two complex numbers will be
> added normally.  If a non-complex is passed in, then the complex
> number's real portion will have the value of the argument added to
> itself, and the imaginary component will not change as the imag method
> for the non-complex number argument returns zero.
> 

Hi, it looks OK to me but I've only been studying Smalltalk for a few weeks. I couldn't 
say if it would cause problems in some bizarre way...

thanks for the help.

