// file: lecture_09/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)); fprintf(stdout, "a short integer is %d bytes\n", sizeof(short int)); fprintf(stdout, "a float is %d bytes\n", sizeof(float)); fprintf(stdout, "a double is %d bytes\n", sizeof(double)); // 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); fprintf(stdout, "a | b = %d\n", a | b); fprintf(stdout, "a ^ b = %d\n", a ^ b); fprintf(stdout, "~a = %d\n", ~a); fprintf(stdout, "a << 1 = %d\n", a << 1); fprintf(stdout, "a >> 1 = %d\n", a >> 1); // short integers // short int s = argv1; fprintf(stdout, "s << 1 = %d\n", s << 1); fprintf(stdout, "s >> 1 = %d\n", s >> 1); // short integers // /* short int ss = (argv1 * argv2) & argv1; fprintf(stdout, "ss = %ld\n", ss); */ // exit gracefully // return true; }