MIPI_AdvancedC_FRTK/Lect1/07_page_11.c

23 lines
645 B
C
Raw Normal View History

2024-11-14 08:45:50 +03:00
#include <stdio.h>
#include <stdint.h>
int main(void)
{
uint32_t a = 60; /* 60 = 0011 1100 */
uint32_t b = 13; /* 13 = 0000 1101 */
int32_t c = 0;
c = a & b; /* 12 = 0000 1100 */
printf("Line 1 c = %u\n", c );
c = a | b; /* 61 = 0011 1101 */
printf("Line 2 c = %u\n", c );
c = a ^ b; /* 49 = 0011 0001 */
printf("Line 3 c = %u\n", c );
c = ~a; /*-61 = 1100 0011 */
printf("Line 4 c = %d\n", c );
c = a << 2; /* 240 = 1111 0000 */
printf("Line 5 c = %u\n", c );
c = a >> 2; /* 15 = 0000 1111 */
printf("Line 6 c = %u\n", c );
return 0;
}