LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 01-05-2005, 09:44 PM   #1
blackzone
Member
 
Registered: Jun 2004
Posts: 256

Rep: Reputation: 30
printf unsigned long long int?


how do I printf an unsigned long long int( aka uint64_t ).

%s for string
%??? for unsigned long long int?
 
Old 01-05-2005, 09:58 PM   #2
leonscape
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Debian SID / KDE 3.5
Posts: 2,313

Rep: Reputation: 48
From the manuals:

'%ll', '%L', '%q'
Specifies that the argument is a long long int or unsigned long long int. (The long long type is an extension supported by the GNU C compiler. For systems that don't provide extra-long integers, this is the same as long int.) The `q' modifier is another name for the same thing, which comes from 4.4 BSD; a long long int is sometimes called a "quad" int.
 
Old 01-05-2005, 10:15 PM   #3
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
I've found %lld to be the most portable.
 
Old 07-22-2006, 09:51 PM   #4
Turb0flat4
LQ Newbie
 
Registered: Jul 2006
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by itsme86
I've found %lld to be the most portable.
Actually, for unsigned long long int, the correct form should be %llu.

At least that's the case for my Apple-derived gcc for mac os x.
 
Old 07-22-2006, 11:08 PM   #5
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
And of course you won't be at all surprised that Microsoft does it differently; it uses "I64" instead of "ll":
Code:
EXAMPLE:
  INT64 x = 1234567890123456;
  printf("The 64 bit number is: %I64d\n",x;)
Sigh...

Last edited by paulsm4; 07-23-2006 at 12:43 AM.
 
Old 07-22-2006, 11:28 PM   #6
xhi
Senior Member
 
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
Quote:
Originally Posted by paulsm4
And of course you won't be at all surprised that Microsoft does it differently; it uses "I64" instead of "ll":

Sigh...
very out of character for microsoft..
 
Old 07-23-2006, 12:43 AM   #7
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Indeed - totally out of character for Microsoft ;-)

From Bruce Schneier's (brilliant!) book, "Secrets and Lies":
Quote:
Kerberos is part of Windows 2000, but Microsoft's implementation differs from the standard and is incompatible with the rest of the Kerberos world. I can only assume this was done for deliberate marketing reasons...
 
Old 07-23-2006, 01:24 AM   #8
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
See <inttypes.h>

According to the latest C standard (C99), we should use the PRIu64 macro and PRId64 for signed 64-bit integers. The most portable way may be to define this macro if it isn't already defined.
 
Old 07-23-2006, 01:43 AM   #9
blackzone
Member
 
Registered: Jun 2004
Posts: 256

Original Poster
Rep: Reputation: 30
500 days old thread... wow

That's why I like this forum. Easy to search old post.
 
Old 03-04-2008, 12:41 PM   #10
bassplayer3579
LQ Newbie
 
Registered: Mar 2008
Posts: 1

Rep: Reputation: 0
%lld and %llu works with windows

Last edited by bassplayer3579; 03-04-2008 at 12:55 PM.
 
  


Reply



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
How to print unsigned long int alaios Programming 6 07-14-2005 10:27 AM
convert unsigned char * to unsigned long int linux_lover2005 Programming 3 04-26-2005 11:38 PM
64 bit CPU unsigned long int GodSendDeath Programming 8 03-29-2005 01:19 PM
int value larger then unsigned long jpc82 Programming 3 03-12-2004 03:54 PM
int, long in char * marek Programming 10 09-01-2003 10:43 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:27 AM.

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
Open Source Consulting | Domain Registration