Path: news.mathworks.com!newsfeed-00.mathworks.com!news.kjsl.com!newsfeed.stanford.edu!elk.ncren.net!newsflash.concordia.ca!canopus.cc.umanitoba.ca!tribune.usask.ca!support1.mathforum.org!not-for-mail
From: bogfrog <jmcgraw@rcn.com>
Newsgroups: comp.soft-sys.matlab
Subject: count number of "on" bits?
Date: Tue, 29 Jul 2008 23:57:12 EDT
Organization: The Math Forum
Lines: 5
Message-ID: <3817980.1217390262927.JavaMail.jakarta@nitrogen.mathforum.org>
NNTP-Posting-Host: nitrogen.mathforum.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: support1.mathforum.org 1217390262 32103 144.118.30.135 (30 Jul 2008 03:57:42 GMT)
X-Complaints-To: news@support1.mathforum.org
NNTP-Posting-Date: Wed, 30 Jul 2008 03:57:42 +0000 (UTC)
Xref: news.mathworks.com comp.soft-sys.matlab:482530



How would I do a bitcount in matlab?

For example, say I have the unsigned 8 bit integer 170, which is '10101010'.  Is there a function to count that it has 4 "on" (1) bits?

Thanks.