how to make a long long

Adrian Sandor aditsu@yahoo.com
Thu Feb 20 09:58:00 GMT 2003


--- Mihnea Balta <dark_lkml@mymail.ro> wrote:
>     union{
>         struct{
>             unsigned long long a:32;
>             unsigned long long b:32;
>         } gigi;
>         unsigned long long l;
>     } toto;
>     toto.gigi.a = 0xFFFFFFFF;
>     toto.gigi.b = 0xFFFFFFFF;

this might be the best way
but why use unsigned long bit fields and not just
unsigned ints? (or unsigned longs)
e.g. struct{unsigned int a,b;}gigi;

>     unsigned long long l;
>     l = 0xFFFFFFFF;
>     l <<= 32;
>     l += 0xFFFFFFFF;

this involves some calculations.. I doubt that the
compiler can optimize them

>     unsigned long long referenceval;
>     memset(&referenceval, 0xFF,
> sizeof(referenceval));

this works if the bytes are identical.. but usually
they are not

thanks for the reply

Adrian


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/



More information about the Gcc-help mailing list