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. |
|
 |
03-28-2005, 02:12 PM
|
#1
|
|
Member
Registered: Mar 2004
Posts: 71
Rep:
|
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
|
|
|
|
03-28-2005, 02:36 PM
|
#2
|
|
Member
Registered: Mar 2005
Location: singapore
Distribution: puppy and Ubuntu and ... erh ... redhat(sort of) :( ... + the venerable bsd and solaris ^_^
Posts: 658
Rep:
|
maybe you can try :
signed long long int
unsigned long long int
|
|
|
|
03-28-2005, 02:46 PM
|
#3
|
|
Senior Member
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246
Rep:
|
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.
|
|
|
|
03-28-2005, 03:42 PM
|
#4
|
|
Member
Registered: Jul 2004
Location: Spain
Posts: 111
Rep:
|
You can also use the __u64 (and all its variants) type by including <linux/types.h>
|
|
|
|
03-28-2005, 03:43 PM
|
#5
|
|
Member
Registered: Mar 2004
Posts: 71
Original Poster
Rep:
|
Thanks for the quick response. Ill try all suggestions and post any interesting results.
-GSD
|
|
|
|
03-28-2005, 04:04 PM
|
#6
|
|
Member
Registered: Jul 2004
Location: Spain
Posts: 111
Rep:
|
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 04:05 PM.
|
|
|
|
03-28-2005, 04:07 PM
|
#7
|
|
Member
Registered: Mar 2004
Posts: 71
Original Poster
Rep:
|
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
|
|
|
|
03-29-2005, 11:05 AM
|
#8
|
|
Member
Registered: Dec 2004
Location: India
Distribution: Fedora Core 4
Posts: 145
Rep:
|
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
|
|
|
|
03-29-2005, 01:19 PM
|
#9
|
|
Senior Member
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246
Rep:
|
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
|
|
|
|
| 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 02:36 AM.
|
|
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
|
|