help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: int8(0) == int16(0) [ was Re: int8(0)==0 ? ]


From: John W. Eaton
Subject: Re: int8(0) == int16(0) [ was Re: int8(0)==0 ? ]
Date: Sun, 5 Sep 2004 15:38:30 -0400

On  5-Sep-2004, David Bateman <address@hidden> wrote:

| According to John W. Eaton <address@hidden> (on 09/04/04):
| > On  3-Sep-2004, Josep Monés i Teixidor <address@hidden> wrote:
| > 
| > | I've tested now int8(0) == int16(0) and isequal(int8(0),int16(0)) and
| > | these don't work. From documentation, I believe that MATLAB answers 1 to
| > | both.
| > | 
| > | 
| > | octave:164> int8(0)==int16(0)
| > | error: binary operator `==' not implemented for `int8 scalar' by `int16
| > | scalar' operations
| > 
| > | octave:164> isequal(int8(0),int16(0))
| > | error: can't perform indexing operations for int8 scalar type
| > 
| > I've just checked in a set of changes that makes these (and many other
| > similar mixed-type) operations work as you would expect.
| 
| I noticed the comment about 64-bit types in the code, but what happens
| with an example like 
| 
| intmax("uint64") - uint64(1) == intmax("uint64")
| 
| casting to double before comparing will ensure that the above statement
| returns true when it should return false...

Yes, I know it is not correct.  We need specializations for the int64
types.  It is a bit tricky.  What is the proper way to compare int64
and uint64 so that you always get the correct result?  I'd also like
to avoid warnings from gcc about possible wrong results due to
comparison of signed and unsigned types, even if that path through the
code is not actually possible.  I could not see a good way to do that.

jwe



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]