From bug-octave-request at bevo dot che dot wisc dot edu Thu Oct 12 04:49:19 2000 Subject: Re: Odd results from &, |, % functions From: Kai Habel To: Carsten Rasmussen CC: bug-octave at bevo dot che dot wisc dot edu Date: Thu, 12 Oct 2000 11:49:58 +0200 Carsten Rasmussen schrieb: > > Hello octave-bug > I have tried the as follows with octave. > > --------- > /home/carsten> octave > GNU Octave, version 2.0.16 (alpha-suse-linux-gnu). > Copyright (C) 1996, 1997, 1998, 1999, 2000 John W. Eaton. > This is free software with ABSOLUTELY NO WARRANTY. > For details, type `warranty'. > > octave:1> 7 & 4 > ans = 1 > octave:2> 5 | 3 > ans = 1 > octave:3> 7 % 4 > ans = 7 > octave:4 > ----------- > > I expected that & and | operator should work as an bitwise-AND and bitwise-OR > (as in C and MATLAB) > I would expect. > octave:1> 7 & 4 > ans = 4 > octave:2> 5 | 3 > ans = 7 > > And the remain remain operator % is interpret as a comment(#)? > I would expect: > octave:3> 7 % 4 > ans = 3 > Hello Carsten, the examples you described, work the same way in matlab. To get bitwise logical operation you have to use bitand, bitor, ... in matlab. I have implemented bit operations for octave, but you have to compile these yourself. You can get them at http://user.berlin.de/~kai.habel - take the tarball. To get the remainder after division use: rem(7,4) ----------------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.che.wisc.edu/octave/octave.html How to fund new projects: http://www.che.wisc.edu/octave/funding.html Subscription information: http://www.che.wisc.edu/octave/archive.html -----------------------------------------------------------------------