Packing/unpacking binary data in C - doubles, 64 bits
bruce.labitt at autoliv.com
bruce.labitt at autoliv.com
Fri Sep 11 09:09:23 EDT 2009
gnhlug-discuss-bounces at mail.gnhlug.org wrote on 09/10/2009 10:12:12 PM:
>
>
> Ooops - I forgot about the void * ...
>
> >> 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
unsignedlong) );
> 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( unsignedchar)
);
> printf( "sizeof( unsigned long) %2u\n", sizeof( unsignedlong)
);
> printf( "sizeof( unsigned short) %2u\n", sizeof( unsignedshort)
);
> printf( "sizeof( void *) %2u\n", sizeof( void
> *) ); /* Fprgot this one */
> }
>
Here are the sizes run on the two platforms, both 64 bit OS. Identical.
P4 Cell
double 8 8
float 4 4
long double 16 16
long signed long 8 8
long unsigned long 8 8
signed char 1 1
signed long 8 8
signed short 2 2
unsigned char 1 1
unsigned long 8 8
unsigned short 2 2
void * 8 8
-Bruce
******************************
Neither the footer nor anything else in this E-mail is intended to or constitutes an <br>electronic signature and/or legally binding agreement in the absence of an <br>express statement or Autoliv policy and/or procedure to the contrary.<br>This E-mail and any attachments hereto are Autoliv property and may contain legally <br>privileged, confidential and/or proprietary information.<br>The recipient of this E-mail is prohibited from distributing, copying, forwarding or in any way <br>disseminating any material contained within this E-mail without prior written <br>permission from the author. If you receive this E-mail in error, please <br>immediately notify the author and delete this E-mail. Autoliv disclaims all <br>responsibility and liability for the consequences of any person who fails to <br>abide by the terms herein. <br>
******************************
More information about the gnhlug-discuss
mailing list