From bug-request at octave dot org Wed Jul 21 11:55:46 2004 Subject: Re: return type of uint(8) .^ uint8(1) From: "John W. Eaton" To: David Bateman Cc: Andy Adler , bug@octave.org Date: Wed, 21 Jul 2004 12:54:58 -0400 On 21-Jul-2004, David Bateman wrote: | One place where you have gotten the saturation behaviour wrong is the | bitshift function. Looking at the link | | http://www.mathworks.com/access/helpdesk/help/techdoc/ref/bitshift.html | | It clearly states that | | "If the shift causes C to overflow the number of bits in the unsigned | integer class of A, then the overflowing bits are dropped" | | and | | "C = bitshift(A, k, n) where A is double precision, causes any bits | that overflow n bits to be dropped. the value of n must be less than | or equal to 53." | | So bitshift should NOT saturate. Whereas at the moment | | octave:1> bitshift(uint8(128),1) | ans = 255 | | which shows a clear saturation... OK, yes this should be fixed. I checked in the bitfcns.cc file before it was finished because I was out of time to work on it, at leat temporarily, but it was already listed in a Makefile.in file that was checked in, and at the time it seemed simpler to check in the .cc file than go back and fix up the Makefile.in file. | > If you are using the latest version of Matlab (just released in the | > last few months) and these operators are not defined, then I have no | > idea why they did not implement them. I think I skipped it for | > Octave initially because there was no template for it that was in the | > right location and I was running out of time to work on integer types. | | Don't have access to R14, and who cares if they don't define them. If they | makes sense the fact that Matlab doesn't have them doesn't mean that Octave | shouldn't... My point was not that Octave should only define operations that Matlab has, but that I wasn't sure why Andy's version of Matlab (whatever it is) does not define this operation. Older versions of Matlab did not define very many (if any) arithmetic operations for int types. I was trying to point out that it might be that his version of Matlab was not current enough to include the .^ operator for int types. 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 -------------------------------------------------------------