# Thread Subject: to count number of bits

 Subject: to count number of bits From: chitra ranganath Date: 6 Jun, 2011 02:47:04 Message: 1 of 5 hi i want to count total no of bits in this example zb= 00000100 1 0 01000100 0 00111110 0 01000100 0 00000100 0 00000010 this includes a delimiter space too so i don`t knw how do i write a code for this
 Subject: to count number of bits From: dpb Date: 6 Jun, 2011 04:13:49 Message: 2 of 5 On 6/5/2011 9:47 PM, chitra ranganath wrote: > hi i want to count total no of bits in this example zb= 00000100 1 0 > 01000100 0 00111110 0 01000100 0 00000100 0 00000010 this includes a > delimiter space too so i don`t knw how do i write a code for this sum(zb=='1') Assuming it is in character format ("includes a delimiter space" don't see that it could be anything else, just saying)... --
 Subject: to count number of bits From: Roger Stafford Date: 6 Jun, 2011 04:40:04 Message: 3 of 5 dpb wrote in message ... > On 6/5/2011 9:47 PM, chitra ranganath wrote: > > hi i want to count total no of bits in this example zb= 00000100 1 0 > > 01000100 0 00111110 0 01000100 0 00000100 0 00000010 this includes a > > delimiter space too so i don`t knw how do i write a code for this > > sum(zb=='1') > > Assuming it is in character format ("includes a delimiter space" don't > see that it could be anything else, just saying)... - - - - - - - - -   Since zeros are bits too, I would think the total number of bits should be:  sum(zb=='1'|zb=='0') Roger Stafford
 Subject: to count number of bits From: Sadik Date: 6 Jun, 2011 04:54:04 Message: 4 of 5 Another one: sum(~isspace(zb)) Best.
 Subject: to count number of bits From: dpb Date: 6 Jun, 2011 12:40:28 Message: 5 of 5 On 6/5/2011 11:40 PM, Roger Stafford wrote: > dpb wrote in message ... >> On 6/5/2011 9:47 PM, chitra ranganath wrote: >> > hi i want to count total no of bits in this example zb= 00000100 1 0 >> > 01000100 0 00111110 0 01000100 0 00000100 0 00000010 this includes a >> > delimiter space too so i don`t knw how do i write a code for this >> >> sum(zb=='1') >> >> Assuming it is in character format ("includes a delimiter space" don't >> see that it could be anything else, just saying)... > - - - - - - - - - > Since zeros are bits too, I would think the total number of bits should be: > > sum(zb=='1'|zb=='0') Hmmmmm....I interpreted it as total number of set bits but you're right he doesn't say that exactly. Guess OP can choose which it is wants. --

Separated by commas
Ex.: root locus, bode

### What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.