[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 32b long int???????
Felix Kollmann wrote:
>
> Hi,
>
> I need a 64b number but int and long are just 32b.
> But long should be 64b.
No - all that C/C++ guarantees is that a long is no shorter
than an int.
Some compilers support "long long int x ;"
Some compilers *do* produce 64 bits for a 'long int'. (eg SGI's
IRIX C compiler will do that if you build 'n64' format binaries).
> How can I get a 64b long?
>
> Perhaps: long test[2] ?
Well - yes - but you can't treat 'test' as a simple number and do
math on it and such. You'd have to write code like:
void increment_64bit ( unsigned int test[2] )
{
if ( test[0] == 0xFFFFFFFF )
{
test[0]=0;
test[1]++ ;
}
else
test[0]++ ;
}
There really isn't a reliable/portable way to guarantee 64 bit
arithmetic in C/C++.
--
Steve Baker http://web2.airmail.net/sjbaker1
sjbaker1@airmail.net (home) http://www.woodsoup.org/~sbaker
sjbaker@hti.com (work)