The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
Google UNIX.COM


High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
to get the correct value with unsigned int naan High Level Programming 2 04-11-2007 03:29 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-02-2002
Registered User
 

Join Date: Jan 2002
Posts: 2
Stumble this Post!
Question Unsigned int

How can I store and/or print() a number that is larger than 4 294 967 295 in C? is int64_t or u_int64_t what I need ? if, so how can I printf it to stdout?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-02-2002
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,430
Stumble this Post!
On HP-UX, this program works:
Code:
#include<stdlib.h>
#include<stdio.h>
main()
{
         long i;
         i=5000000000;
         printf("i = %ld \n", i);
          exit (0);
}
To get this to work I had to specify the +DD64 option on the cc command. HP's compiler defaults to 32 bit mode.

This page says:
Quote:
The HP-UX 64-bit data model is called LP64 because longs and pointers are 64 bits. In this model, ints remain 32 bits.

The LP64 data model is the emerging standard on 64-bit UNIX systems provided by leading system vendors. Applications that transition to the LP64 data model on HP-UX systems are highly portable to other LP64 vendor platforms.
Reply With Quote
  #3 (permalink)  
Old 03-03-2002
Registered User
 

Join Date: Feb 2002
Location: Brabant, Belgium
Posts: 65
Stumble this Post!
I wasn't sure is this was HP-UX specific, there is a weirdicious feature in GCC that will make the aforementioned program work with two changes (at least under Linux)

Use data type

long long l; /* Not typo! will compile */

and printf("%Ld", l); /* Notice capital L */

If GCC is used on various Os'es, it should work.
(I just checked on Solaris, it prints 1 :-(


Atle
__________________
PS
All of the above is to be read as '... unless I am wrong'
ENDPS
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 11:09 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0