LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   64 bit integer (https://www.linuxquestions.org/questions/programming-9/64-bit-integer-85043/)

fahad153 08-23-2003 11:17 PM

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

leonscape 08-23-2003 11:22 PM

64bit integer in Linux?

What language are we talking here? bash script, c, c++, python...

Robert0380 08-24-2003 04:12 AM

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.

llama_meme 08-24-2003 07:36 AM

You should be able to use "long long" with gcc, in what way did it not work?

Alex

kev82 08-24-2003 08:16 AM

theres some sort of bug in gcc 3.3, but it works fine for me in gcc 3.2

Robert0380 08-24-2003 01:07 PM

there is such a thing as a 64-bit int. I was downloading the latest version of BIND and found this:

Quote:


BIND 9 currently requires a UNIX system with an ANSI C compiler, basic POSIX support, and a 64 bit integer type.



there is porbably a typedef for it already pre-defined somewhere (if you are using C).

moeminhtun 08-25-2003 01:29 AM

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.

Dark_Helmet 08-25-2003 01:52 AM

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.

llama_meme 08-25-2003 02:29 AM

Quote:

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.
I don't think this is true for the (quasi) 64-bit processors of the x86 architecture, you have to use "long long" to get a 64-bit int. It would be helpful if the original poster would say exactly what problem he had with this solution in Redhat.

Alex

devoyage 08-26-2003 02:03 AM

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.