LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   printf unsigned long long int? (http://www.linuxquestions.org/questions/programming-9/printf-unsigned-long-long-int-274423/)

blackzone 01-05-2005 09:44 PM

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?

leonscape 01-05-2005 09:58 PM

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.

itsme86 01-05-2005 10:15 PM

I've found %lld to be the most portable.

Turb0flat4 07-22-2006 09:51 PM

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.:)

paulsm4 07-22-2006 11:08 PM

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...

xhi 07-22-2006 11:28 PM

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..

paulsm4 07-23-2006 12:43 AM

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...

primo 07-23-2006 01:24 AM

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.

blackzone 07-23-2006 01:43 AM

500 days old thread... wow

That's why I like this forum. Easy to search old post.

bassplayer3579 03-04-2008 12:41 PM

%lld and %llu works with windows


All times are GMT -5. The time now is 03:54 PM.