Path: news.mathworks.com!newsfeed-00.mathworks.com!kanaga.switch.ch!switch.ch!newsfeed00.sul.t-online.de!t-online.de!news.k-dsl.de!aioe.org!not-for-mail
From: Clemens <Clemi@hotmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Problem with very simple script
Date: Wed, 29 Oct 2008 17:04:09 +0000
Organization: Aioe.org NNTP Server
Lines: 23
Message-ID: <gea529$cgk$1@aioe.org>
Reply-To: Clemi@hotmail.com
NNTP-Posting-Host: iwazocMqq37NFvTzXicAGg.user.aioe.org
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Complaints-To: abuse@aioe.org
NNTP-Posting-Date: Wed, 29 Oct 2008 17:04:09 +0000 (UTC)
X-Notice: Filtered by postfilter v. 0.7.4
User-Agent: Thunderbird 1.5.0.12 (X11/20070529)
Xref: news.mathworks.com comp.soft-sys.matlab:497845


Hi

I have a very simple problem. I have a 32-bit integer value and
I wanna store each byte of this word in one chunk of 8-bits. So my idea 
was using a bitmask that extracts me each byte and then I wanna use
bitsra to rightshift the extract byte to the LSB and use then another
bitand to extract the final byte value. However, in the code fragement
below I get the error message that bitsra cant be used on values from 
type 'double'. Anyone an idea how I could get around this problem?

LSB   = 255;
mask  = 255;
value = 3545883001; %D359E179

chunk(1) = bitand(value,mask);

for i=2:4
   mask     = bitshift(mask,8);
   chunk(i) = bitand(bitsra(bitand(value,mask),(i-1)*8),LSB);
end

Many thanks,
Clemens!