Click here to Skip to main content
15,917,005 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Question mark icon in title bar Pin
JensB30-Apr-03 6:28
JensB30-Apr-03 6:28 
GeneralRe: Question mark icon in title bar Pin
David Crow30-Apr-03 8:52
David Crow30-Apr-03 8:52 
GeneralRe: Question mark icon in title bar Pin
Michael Dunn1-May-03 0:29
sitebuilderMichael Dunn1-May-03 0:29 
GeneralRe: Question mark icon in title bar Pin
JensB1-May-03 23:34
JensB1-May-03 23:34 
General3 Tier Question Pin
nlecren30-Apr-03 3:14
nlecren30-Apr-03 3:14 
GeneralRe: 3 Tier Question Pin
David Crow30-Apr-03 3:26
David Crow30-Apr-03 3:26 
GeneralRe: 3 Tier Question Pin
nlecren30-Apr-03 3:42
nlecren30-Apr-03 3:42 
QuestionIs there a fast method for doing this? Pin
chen30-Apr-03 3:11
chen30-Apr-03 3:11 
Hi,

For binary string i have following loop which calculate the
difference of 0' and 1'.

int CMyDlg::ZeroOneDiff(char *str, int length, char sbit)
{
int i;
char tmp;
char backup[60];
int iZero, iOne;
int iDiff;

tmp = sbit;
memset(backup, 0, 28);
for(i=0; i<length; i++){
if(="" (str[i]="=" '1')="" &&="" (tmp="=" '0'))="" {
backup[i]="1" ;
}
else="" if(="" '1')){
backup[i]="0" if((str[i]="=" '0')="" '0')){
backup[i]="0" '1'))="" ;
}
tmp="backup[i];
}
iZero" =="" 0;
ione="0;
iDiff" 0;
for(i="0;" i<length;="" i++){
if(backup[i]="=" izero++;
else="" ione++;
}
idiff="" +="(iZero" -="" ione);
return="" idiff;
}

for="" example,="" for="" binary="" string="010001000100100" and="" start
bit="" '0',="" we="" can="" call="" above="" function="" as

int="" diff="ZeroOneDiff(string," 15,="" '0');

i="" really="" want="" to="" know="" if="" there="" is="" a="" fast="" method="" doing="" this="" (using="" &,="" |,="" ^,="" <<,="">> operators )? especially, when the length of the binary string is bigger, the fast method is more valuable.

Thanks in advance!



chen
AnswerRe: Is there a fast method for doing this? Pin
David Crow30-Apr-03 3:23
David Crow30-Apr-03 3:23 
GeneralRe: Is there a fast method for doing this? Pin
chen30-Apr-03 3:35
chen30-Apr-03 3:35 
GeneralRe: Is there a fast method for doing this? Pin
David Crow30-Apr-03 6:03
David Crow30-Apr-03 6:03 
GeneralRe: Is there a fast method for doing this? Pin
chen30-Apr-03 6:18
chen30-Apr-03 6:18 
GeneralRe: Is there a fast method for doing this? Pin
Rage30-Apr-03 6:19
professionalRage30-Apr-03 6:19 
AnswerRe: Is there a fast method for doing this? Pin
Sean Cundiff30-Apr-03 5:14
Sean Cundiff30-Apr-03 5:14 
GeneralRe: Is there a fast method for doing this? Pin
chen30-Apr-03 5:49
chen30-Apr-03 5:49 
GeneralRe: Is there a fast method for doing this? Pin
David Crow30-Apr-03 5:56
David Crow30-Apr-03 5:56 
GeneralRe: Is there a fast method for doing this? Pin
Anonymous30-Apr-03 9:05
Anonymous30-Apr-03 9:05 
GeneralRe: Is there a fast method for doing this? Pin
David Crow30-Apr-03 10:08
David Crow30-Apr-03 10:08 
GeneralRe: Is there a fast method for doing this? Pin
Anonymous1-May-03 7:27
Anonymous1-May-03 7:27 
GeneralRe: Is there a fast method for doing this? Pin
David Crow1-May-03 7:52
David Crow1-May-03 7:52 
GeneralRe: Is there a fast method for doing this? Pin
Anonymous2-May-03 8:10
Anonymous2-May-03 8:10 
GeneralRe: Is there a fast method for doing this? Pin
David Crow2-May-03 8:24
David Crow2-May-03 8:24 
GeneralA question about IE Pin
Carlos Antollini30-Apr-03 2:52
Carlos Antollini30-Apr-03 2:52 
GeneralRe: A question about IE Pin
Anonymous30-Apr-03 3:10
Anonymous30-Apr-03 3:10 
GeneralRe: A question about IE Pin
Stephane Rodriguez.30-Apr-03 3:17
Stephane Rodriguez.30-Apr-03 3:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.