Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
08-23-2003, 11:17 PM
|
#1
|
|
LQ Newbie
Registered: Aug 2003
Posts: 1
Rep:
|
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
|
|
|
|
08-23-2003, 11:22 PM
|
#2
|
|
Senior Member
Registered: Aug 2003
Location: UK
Distribution: Debian SID / KDE 3.5
Posts: 2,313
Rep:
|
64bit integer in Linux?
What language are we talking here? bash script, c, c++, python...
|
|
|
|
08-24-2003, 04:12 AM
|
#3
|
|
Guru
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280
Rep:
|
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.
|
|
|
|
08-24-2003, 07:36 AM
|
#4
|
|
Member
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590
Rep:
|
You should be able to use "long long" with gcc, in what way did it not work?
Alex
|
|
|
|
08-24-2003, 08:16 AM
|
#5
|
|
Senior Member
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263
Rep:
|
theres some sort of bug in gcc 3.3, but it works fine for me in gcc 3.2
|
|
|
|
08-24-2003, 01:07 PM
|
#6
|
|
Guru
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280
Rep:
|
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).
|
|
|
|
08-25-2003, 01:29 AM
|
#7
|
|
Member
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647
Rep:
|
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.
|
|
|
|
08-25-2003, 01:52 AM
|
#8
|
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
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.
|
|
|
|
08-25-2003, 02:29 AM
|
#9
|
|
Member
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590
Rep:
|
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
|
|
|
|
08-26-2003, 02:03 AM
|
#10
|
|
Member
Registered: Aug 2003
Distribution: many
Posts: 37
Rep:
|
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.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 08:04 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|