LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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

Reply
 
Search this Thread
Old 08-24-2003, 12:17 AM   #1
fahad153
LQ Newbie
 
Registered: Aug 2003
Posts: 1

Rep: Reputation: 0
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
 
Old 08-24-2003, 12:22 AM   #2
leonscape
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Debian SID / KDE 3.5
Posts: 2,313

Rep: Reputation: 47
64bit integer in Linux?

What language are we talking here? bash script, c, c++, python...
 
Old 08-24-2003, 05:12 AM   #3
Robert0380
Guru
 
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280

Rep: Reputation: 47
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.
 
Old 08-24-2003, 08:36 AM   #4
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

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

Alex
 
Old 08-24-2003, 09:16 AM   #5
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 50
theres some sort of bug in gcc 3.3, but it works fine for me in gcc 3.2
 
Old 08-24-2003, 02:07 PM   #6
Robert0380
Guru
 
Registered: Apr 2002
Location: Atlanta
Distribution: Gentoo
Posts: 1,280

Rep: Reputation: 47
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).
 
Old 08-25-2003, 02:29 AM   #7
moeminhtun
Member
 
Registered: Dec 2002
Location: Singapore
Distribution: Fedora Core 6
Posts: 647

Rep: Reputation: 30
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.
 
Old 08-25-2003, 02:52 AM   #8
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
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.
 
Old 08-25-2003, 03:29 AM   #9
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
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
 
Old 08-26-2003, 03:03 AM   #10
devoyage
Member
 
Registered: Aug 2003
Distribution: many
Posts: 37

Rep: Reputation: 15
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Integer Numbers in C Mercurius Programming 24 10-20-2005 10:54 AM
Which version of 32 bit redhat will install on IBM xSeries 366 (64 bit)? Hello123 Linux - Hardware 2 09-14-2005 06:50 AM
C, read 8 bit octal numbers, convert to 24 bit binary bamalabs Programming 3 01-20-2004 10:59 AM
Graphic Card that Supports displaying 8-bit and 24-bit images simultaneously yrraja Linux - Hardware 2 04-30-2003 07:41 AM
Displaying 8-bit images in 24-bit mode and vice versa yrraja Linux - General 4 04-30-2003 12:54 AM


All times are GMT -5. The time now is 10:00 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration