X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=dump-float.c;h=718d2a113bb1f593a43487d10469933dd1757f95;hb=0ee5ac77918b105dd6a5f8469947b9f040bd2bfa;hp=4257ca17cd063bb2f1904b2fefccc5c11c6c86fb;hpb=55083a4e71e2027e4ddea318f2128ba9a7636c10;p=pspp diff --git a/dump-float.c b/dump-float.c index 4257ca17cd..718d2a113b 100644 --- a/dump-float.c +++ b/dump-float.c @@ -1,15 +1,33 @@ #include #include +#include + +void +print_double (const uint8_t *b) +{ + double d; + memcpy (&d, b, 8); + printf ("%f\n", d); +} + +void +print_float (const uint8_t *b) +{ + float d; + memcpy (&d, b, 4); + printf ("%f\n", d); +} int main (void) { - union - { - uint8_t b[8]; - double d; - } - x = { .b = { 0xfa, 0x3c, 0x00, 0x00, 0x3b, 0x5a, 0x01, 0x00 } }; - printf ("%f\n", x.d); + uint8_t b[] = { 0xc3, 0xe2, 0xb7, 0xc2, 0xb0, 0xe1, 0xb0, 0xfa }; + int n = sizeof b; + for (int i = 0; i <= n - 8; i++) + print_double (b + i); +/* + for (int i = 0; i <= n - 4; i++) + print_float (b + i); +*/ return 0; }