From help-request at octave dot org Sun Sep 5 14:42:36 2004 Subject: Re: int8(0) == int16(0) [ was Re: int8(0)==0 ? ] From: "John W. Eaton" To: David Bateman Cc: Josep =?iso-8859-1?Q?Mon=E9s?= i Teixidor , "Llista help a octave.org" Date: Sun, 5 Sep 2004 15:38:30 -0400 On 5-Sep-2004, David Bateman wrote: | According to John W. Eaton (on 09/04/04): | > On 3-Sep-2004, Josep Mon=E9s i Teixidor wro= te: | >=20 | > | I've tested now int8(0) =3D=3D int16(0) and isequal(int8(0),int16= (0)) and | > | these don't work. From documentation, I believe that MATLAB answe= rs 1 to | > | both. | > |=20 | > |=20 | > | octave:164> int8(0)=3D=3Dint16(0) | > | error: binary operator `=3D=3D' not implemented for `int8 scalar'= by `int16 | > | scalar' operations | >=20 | > | octave:164> isequal(int8(0),int16(0)) | > | error: can't perform indexing operations for int8 scalar type | >=20 | > I've just checked in a set of changes that makes these (and many ot= her | > similar mixed-type) operations work as you would expect. |=20 | I noticed the comment about 64-bit types in the code, but what happen= s | with an example like=20 |=20 | intmax("uint64") - uint64(1) =3D=3D intmax("uint64") |=20 | casting to double before comparing will ensure that the above stateme= nt | 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=3F 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 -------------------------------------------------------------