LinuxQuestions.org
Register a domain and help support LQ
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 03-28-2005, 03:12 PM   #1
GodSendDeath
Member
 
Registered: Mar 2004
Posts: 71

Rep: Reputation: 15
64 bit CPU unsigned long int


Please correct me if im wrong...

In a 32 bit CPU, the "unsigned long int" data type has a max value of
(2^32)-1....

In a 64 bit CPU (AMD64 for example), will the "unsigned long int" data type
have a max value of (2^64)-1?

I am working on a Solaris Sparc III machine which consists of 64 bit CPUS. However, the unsigned long int number appears to be restricted to the legacy 2^32 size. This may be due to admin configuration (not my server). Any information would be appreciated.


-GSD
 
Old 03-28-2005, 03:36 PM   #2
alred
Member
 
Registered: Mar 2005
Location: singapore
Distribution: puppy and Ubuntu and ... erh ... redhat(sort of) :( ... + the venerable bsd and solaris ^_^
Posts: 658
Blog Entries: 8

Rep: Reputation: 31
maybe you can try :

signed long long int
unsigned long long int
 
Old 03-28-2005, 03:46 PM   #3
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 58
According to the C standard, a long int has to be at least as big as an int. But it doesn't say anything about how big it will be on whatever architecture. If you need the int to be a certain size (64-bit) then I suggest #include'ing <stdint.h> and using the type uint64_t.
 
Old 03-28-2005, 04:42 PM   #4
Nerox
Member
 
Registered: Jul 2004
Location: Spain
Posts: 111

Rep: Reputation: 20
You can also use the __u64 (and all its variants) type by including <linux/types.h>
 
Old 03-28-2005, 04:43 PM   #5
GodSendDeath
Member
 
Registered: Mar 2004
Posts: 71

Original Poster
Rep: Reputation: 15
Thanks for the quick response. Ill try all suggestions and post any interesting results.

-GSD
 
Old 03-28-2005, 05:04 PM   #6
Nerox
Member
 
Registered: Jul 2004
Location: Spain
Posts: 111

Rep: Reputation: 20
Quote:
Originally posted by Nerox
You can also use the __u64 (and all its variants) type by including <linux/types.h>
I'm sorry, i've thought it more thoroughly, and my proposal won't work on your machine, since your machine is running a Sun Solaris and not a Linux system. That will only work on Linux.

Last edited by Nerox; 03-28-2005 at 05:05 PM.
 
Old 03-28-2005, 05:07 PM   #7
GodSendDeath
Member
 
Registered: Mar 2004
Posts: 71

Original Poster
Rep: Reputation: 15
No Prob. Ive got several to work with... Solaris, FreeBSD, and Linux. Its just Solaris was the only 64 bit architecture I had to work with.


-GSD
 
Old 03-29-2005, 12:05 PM   #8
skie_knite007
Member
 
Registered: Dec 2004
Location: India
Distribution: Fedora Core 4
Posts: 145

Rep: Reputation: 15
It depends on the compiler u r using,I think so.

If u r using GCC,,its 32 bit compiler. So the unsigned int ll be only
2^32-1
 
Old 03-29-2005, 02:19 PM   #9
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 58
Quote:
Originally posted by skie_knite007
It depends on the compiler u r using,I think so.

If u r using GCC,,its 32 bit compiler. So the unsigned int ll be only
2^32-1
Not true. These are compiler options for GCC:
Quote:
-m32
-m64
Generate code for a 32-bit or 64-bit environment. The 32-bit environment sets int, long and pointer to 32 bits and generates code that runs on any i386 system. The 64-bit environment sets int to 32 bits and long and pointer to 64 bits and generates code for AMD's x86-64 architecture.
Here's a link for reference: http://gcc.gnu.org/onlinedocs/gcc-3....002d64-Options
 
  


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
printf unsigned long long int? blackzone Programming 9 03-04-2008 01:41 PM
How to print unsigned long int alaios Programming 6 07-14-2005 11:27 AM
print unsigned int alaios Programming 4 06-03-2005 10:34 AM
convert unsigned char * to unsigned long int linux_lover2005 Programming 3 04-27-2005 12:38 AM
int value larger then unsigned long jpc82 Programming 3 03-12-2004 04:54 PM


All times are GMT -5. The time now is 11:30 PM.

Main Menu
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