[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: logical and ????
From: |
Matthew Flax |
Subject: |
Re: logical and ???? |
Date: |
Thu, 13 Dec 2001 03:34:35 +1100 |
User-agent: |
Mutt/1.2.5i |
On 12 December 2001, Paul Kienzle wrote:
> Thanks to Kai Habel, we have bitand, bitor, etc. as
> oct-files in octave-forge at http://octave.sf.net
> but limited to 32 bits.
>
> I can replace all of the bit functions with m-file
> implementations using arithmetic (+,-,*,/) except
> for bitand. If I can figure out bitand, then we
> can use all the bits of the mantissa for a double
> (which is 53 bits I believe). Any suggestions?
>
> bitxor(a,b) : (a - bitand(a,b)) + (b - bitand(a,b))
> bitor(a,b) : (a - bitand(a,b)) + b
> bitset(a,n) : a + sum(2.^n)
> bitset(a,n,0) : a - bitand(a,sum(2.^n))
> bitget(a,n) : bitand(a,2^n) != 0
> bitshift(a,k) : fix (a * 2^k)
> bitcmp(a) : (2.^bitmax - 1) - a
Wow thats a great idea.
>
> Paul Kienzle
> address@hidden
>
> On Tue, Dec 11, 2001 at 10:40:05PM -0600, John W. Eaton wrote:
> > On 12-Dec-2001, Matthew Flax <address@hidden> wrote:
> >
> > | When I try the following I get a confusing answer :
> > |
> > | octave:47> 0x4 & 0x8
> > | ans = 1
> > |
> > | surely that should be ans=0 ?
> >
> > No. The & and | operators work element-by-element for matrices. Your
> > 0x4 and 0x8 numbers are just scalars, so the result is 1, which tells
> > you that both elements in the comparison are nonzero. If you want
> > bit-wise operations, you need some functions to do it. The matcompat
> > package may have some, but they aren't distributed as a part of Octave
> > (yet).
> >
> > 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
> > -------------------------------------------------------------
> >
--
Matt
For electronic musicians ...
Vector Bass : http://mffmvectorbass.sourceforge.net/
For developers ...
TimeScale Audio Mod : http://mffmtimescale.sourceforge.net/
Multimedia Time Code : http://mffmtimecode.sourceforge.net/
3D Audio Library : http://mffm3daudiolib.sourceforge.net/
-------------------------------------------------------------
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
-------------------------------------------------------------