[Numpy-discussion] Re: numpy, overflow, inf, ieee, and rich , comparison

Pete Forman gsez020 at kryten.bedford.waii.com
Fri Oct 27 05:29:05 EDT 2000


"Steven D. Majewski" <sdm7g at virginia.edu> writes:

> On 26 Oct 2000, Pete Forman wrote:
> 
> > Most of this thread is concerned with whether doing an operation
> > with two integers should produce a result which is not an integer.
> > 
> > What has not been mentioned is that the "2" and "3" are integers.
> > If you want them to be floats they should be spelt "2." and "3."
> > in the same way that longs would be spelt "2L" and "3L".  It may
> > be possible to change the language so that unadorned numbers are
> > floats and some suffix is introduced for integers.  I don't think
> > that you'd get many takers for that.
> 
> I'm not particularly happy that 2000000 * 2000000 gives me an
> overflow error and I have to remember to append an "L" to one or
> more of those operands.

Well I am.  Every arithmetic has some limitation on domains and
ranges.

> Would you suggest that for consistency, 3/2 signal an error, since
> the answer is outside the domain ?

No, the answer (1) is in the domain of Python integers.  The operation
/ is defined as returning the quotient.  Use a different statement if
you want an answer that is rational, float, (quotient, remainder) or
whatever.

> That's not the solution I prefer, but at least it's consistent 
> and it gives a warning rather than the wrong answer. 

But it is the right answer.  You need to be sure that you are asking
the right question.

    HOW OLD CARY GRANT
    OLD CARY GRANT FINE HOW YOU 

-- 
Pete Forman                 -./\.- Disclaimer: This post is originated
Western Geophysical           -./\.-  by myself and does not represent
pete.forman at westgeo.com         -./\.-  the opinion of Baker Hughes or
http://www.crosswinds.net/~petef  -./\.-  its divisions.



More information about the Python-list mailing list