#include #include #include typedef unsigned char byte; void show_bytes(void * start, size_t len){ printf("%lu bytes from %p:", len, start); int i; for(i = 0; i < len; i++){ printf(" %.2x", ((byte *) start)[i]); } printf("\n"); } void normalized_demo(){ float f1 = 1.0; //show_bytes(&f1,4); float f2 = 1.25; //show_bytes(&f2,4); float f3 = 64; //show_bytes(&f3,4); float f4 = -.625; //show_bytes(&f4,4); float f5 = .375; // TODO: replace with answer to float example show_bytes(&f5,4); float f6 = 47; // TODO: replace with answer to exercise 4 show_bytes(&f6,4); } void associativity_demo(){ float a = pow(2,30); float b = -1*a; float c = 3.14; printf("(2^30 + -2^30) + 3.14 = %f\n", (a + b) + c); printf("2^30 + (2^30 + 3.14) = %f\n", a + (b + c)); a = 30002; b = 20001; c = 10003; printf("(30002 * 20001) * 10003 = %f\n", (a * b) * c); printf(" 30002 * (20001 * 10003) = %f\n", a * (b * c)); } int main() { normalized_demo(); associativity_demo(); return 0; }