// file: lecture_10/example_00.cc // // a simple function that doesn't do much // // system include files // #include "example.h" // function: my_function // // arguments: // long arg1: the first argument // long arg2: the second argument // // return: a bool indicating status // bool my_function(long argv1, long argv2) { // how many bytes is a long integer // // fprintf(stdout, "a long integer is %d bytes\n", sizeof(argv1)); // convert the arguments to unsigned char // signed char a = (signed char)argv1; signed char b = (signed char)argv2; // do some bit-level stuff // fprintf(stdout, "a = %d, b = %d\n", a, b); fprintf(stdout, "a & b = %d\n", a & b); // The result is 00000001 fprintf(stdout, "a | b = %d\n", a | b); // The result is 00001101 fprintf(stdout, "a ^ b = %d\n", a ^ b); // The result is 00001100 fprintf(stdout, "~a = %d\n", ~a); // The result is 11111010 fprintf(stdout, "a << 1 = %d\n", a << 1); // The result is 00010010 fprintf(stdout, "a >> 1 = %d\n", a >> 1); // The result is 00000100 // exit gracefully // return true; }