64 bit integer
Hi all,
How can I declear a 64-bit integer in linux and unix enviroment? I tried to ues long long on redhat linux but did not work |
64bit integer in Linux?
What language are we talking here? bash script, c, c++, python... |
i dont think there is such a thing. ints are 32-bits. However, when programming with MCUs, we would use extra variables, take 2 8-bit registers to make the equiv. of a 16-bit register. But that's low level stuff, the same could be done with char's if you wanted to use 8-bit chunks and make then unsigned (0-255).
why do you need a 64-bit int by the way. |
You should be able to use "long long" with gcc, in what way did it not work?
Alex |
theres some sort of bug in gcc 3.3, but it works fine for me in gcc 3.2
|
there is such a thing as a 64-bit int. I was downloading the latest version of BIND and found this:
Quote:
there is porbably a typedef for it already pre-defined somewhere (if you are using C). |
I think 64 bit integer is the integer type of the 64 bit compiler for the 64 bit machines.
64 bit processors have 64 bit registers. So I think, if you are working on a 64 bit machine, if you declare an integer, it's 64 bit automatically. |
Well, I don't know if this will help you or not, but I've got a "huge_int" class that I wrote in C++. It can represent an arbitrary length integer. You specify how many bits the register will use, and it behaves like a normal integer from that point on. I used overloading operators to allow addition by unsigned integers and string representations of integers. In fact, that's how the class is implemented: a string of 1's and 0's. It allows for display in decimal, hex, or binary formats. Most math operators are implemented: addition, subtraction, multiplication, division, +=, -=, etc. I can dig it up if anyone is interested.
Note: I never got around to making it a signed integer. So if you need negative values, then you'll have to modify the class, or add the appropriate twos-complement adjustment when it's displayed. And yes, traditionally, the base size of an integer is the width of a processor's internal registers. So 32-bit machines have 32-bit integers, a 64-bit has 64-bit integers, etc. |
Quote:
Alex |
This might be out of the question for your situation, but you may want to look into the gmp library.... you can go as big (or small) as you want ;)
... just a thought Enjoy. |
All times are GMT -5. The time now is 09:22 PM. |