[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 32b long int???????



> I need a 64b number but int and long are just 32b.
> But long should be 64b.
> 
No it shouldn't. Or well, sometimes it should :)

The deal is this: if you've got yourself a 64-bit platform, long is
64-bit, if you've got a 32-bit platform, long is 32 bit. The same deal
with int and 16-bit and 32-bit platforms (though luckily we don't have
to tihnk about that anymore).

> How can I get a 64b long?
> 
If you have a 32-bit platform, you can't.

Or, well, perhaps you can, but not in standard C++. Your compiler might
have some kind of extension.

I think gcc has a type named "long long" or "longlong" that will give
you 64-bit. MSVC++ has a type named __int64 which will give you 64-bit.

> Perhaps:        long test[2] ?
>
You could do that, but I'd advise you to encapsulate it in a class, as
else it'll be major pain to use that thing. You can't just say "test +
test2", no, you have to do the first addition with the first two longs
of test and test, find out how much "spills over" from that, and then do
a second add with the next two longs of test and test two and add the
"spill over" from the first add (atleast, that's how I think it goes :).

Anyway, its just much nicer to have the compiler do that, if you
compiler supports it.

Else, make a class if you REALLY need it.