Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- void binary(int y)
- {
- int temp;
- putchar('\t');
- for(temp = y ; temp ; temp /= 2 )
- {
- printf("%d",temp%2);
- }
- putchar(27);
- putchar('\n');
- return;
- }
- int main()
- {
- int x,y,z,temp;
- x = 0;
- y = 255;
- z = 128;
- printf("\tLeitura em conceito asi%ctico inicio em %c\n\n",160,27);
- binary(y); /*- binário de y -*/
- printf("or");
- binary(z); /*- binário de z -*/
- x = y|z; /*- operação entre os bits -*/
- binary(x); /*- retorna o resultado -*/
- printf("\t________\n\tBinario = %d",x);
- new_line
- binary(y);
- printf("and");
- binary(z);
- x = y&z;
- binary(x);
- printf("\t________\n\tBinario = %d",x);
- new_line
- binary(y);
- printf("xor");
- binary(z);
- x = y^z;
- binary(x);
- printf("\t________\n\tBinario = %d",x);
- new_line
- printf("\n\tUnario :~\n");
- printf("Antes: \n");
- binary(y);
- printf("Depois :\n");
- binary(~y);
- printf("\n ~ %d := %d ",y,~y);
- printf("\n\t%d um bit de deslocamento %c esquerda: ",10,133);
- x = x = 10 >> 1;
- printf(" >> %d",x);
- printf("\n\t%d um bit de deslocamento %c direita: ",10,133);
- x = x = 10 << 1;
- printf(" << %d\n\n",x);
- scanf("%[^\n]");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement