1. ## bit conversions

does anybody have or know of a bit conversion table or program, or even a website, one that uses the bitwise operators.

for example, something that would give you the bit pattern to change:

1000 0000

to

10010100

using '|' '&' bitwise operators

so like if you know what pattern you start with and you know what pattern you need, a table or program gives you the 2nd bit pattern. need this more for haste instead of trying to calculate the needed bit pattern on my own. thanx in advance.

2. Sounds like homework to me.

1) Read a string of 0s and 1s
2) Read an operator to use.
3) Read a second "binary" string.
4) Apply the "operator".
5) Print the results.

Quzah.

3. ## Re: bit conversions

Originally posted by wazilian
does anybody have or know of a bit conversion table or program, or even a website, one that uses the bitwise operators.

for example, something that would give you the bit pattern to change:

1000 0000

to

10010100

using '|' '&' bitwise operators

so like if you know what pattern you start with and you know what pattern you need, a table or program gives you the 2nd bit pattern. need this more for haste instead of trying to calculate the needed bit pattern on my own. thanx in advance.
change:

a=1000 0000

to

b=10010100

isnt a | b= b in this case )

4. you wanna change between binary to decimal???
well look

you can read the string and then make a for like this

for(i=0;i<strlen(string);i++){
if (string[i]=='1') a|=(1<<strlen-1-i);
}

a is an int....
a is the decimal value of the binary number you saved on the string

5. Originally posted by Null Shinji
you wanna change between binary to decimal???
well look

you can read the string and then make a for like this

for(i=0;i<strlen(string);i++){
if (string[i]=='1') a|=(1<<strlen-1-i);
}

a is an int....
a is the decimal value of the binary number you saved on the string
ahh i forgot from dec to binary..

s[32]=0;
for(int k=0;k<32;k++){
if(c&(1<<k)) s[31-k]='1';
else s[31-k]='0';
}
int l=0;
while(s[l]=='0'){
l++;
}
memmove(s,s+l,33-l);
printf("%s",s);

then s is the string where you keep the binary form of the decimal you saved on c