Packing/unpacking binary data in C - doubles, 64 bits

Bruce Labitt bruce.labitt at myfairpoint.net
Thu Sep 10 22:13:55 EDT 2009


Michael ODonnell wrote:
>   
>> Any suggestions to look for a 2^53 type problem?
>>     
>
> Well, just for fun, how about going back to basics - what does this
> little program generate on all the systems in question?
>
>
> #include "stdio.h"
>
> main( int   argc,
>       char *argv[] )
> {
>     printf( "sizeof(              double) %2u\n", sizeof(              double) );
>     printf( "sizeof(              float)  %2u\n", sizeof(              float)  );
>     printf( "sizeof(long          double) %2u\n", sizeof(long          double) );
>     printf( "sizeof(long signed   long)   %2u\n", sizeof(long signed   long)   );
>     printf( "sizeof(long unsigned long)   %2u\n", sizeof(long unsigned long)   );
>     printf( "sizeof(     signed   char)   %2u\n", sizeof(     signed   char)   );
>     printf( "sizeof(     signed   long)   %2u\n", sizeof(     signed   long)   );
>     printf( "sizeof(     signed   short)  %2u\n", sizeof(     signed   short)  );
>     printf( "sizeof(     unsigned char)   %2u\n", sizeof(     unsigned char)   );
>     printf( "sizeof(     unsigned long)   %2u\n", sizeof(     unsigned long)   );
>     printf( "sizeof(     unsigned short)  %2u\n", sizeof(     unsigned short)  );
> }
>
> _______________________________________________
> gnhlug-discuss mailing list
> gnhlug-discuss at mail.gnhlug.org
> http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/
>
>
>   

I'll try it tomorrow.  I've done some of these, but not all in one fell 
swoop.
I know that sizeof(double) = 8 bytes and sizeof(long long) is 8 bytes on 
my P4.

Pretty sure it is the same on the Cell, but I'll know for sure tomorrow.

-Bruce


More information about the gnhlug-discuss mailing list