YoungJi
asked on
Printing "long long"
How do I output the type "long long" to stdout?
i.e.
I have,
long long number;
and I want to call
printf("???", number);
so that the decimal value of long long is printed. How?
Thanks so much in advance.
i.e.
I have,
long long number;
and I want to call
printf("???", number);
so that the decimal value of long long is printed. How?
Thanks so much in advance.
not sure what a "long long" represents in your compiler, but you could try "%I64"
sorry, I missed a character "%I64d".
ASKER
ummm... that just prints I64d.
And using "%i64d" gives 064d.
I'm dealing with numbers that could be as big as 2^64-1, so I need unsigned long long. Could there be an easier approach?
And using "%i64d" gives 064d.
I'm dealing with numbers that could be as big as 2^64-1, so I need unsigned long long. Could there be an easier approach?
long long ?? Was that ever allowed?
ASKER
yes
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ok, Found it:
Use %lD (note that the 'l' is small and the 'D' is in caps).
You can refer to:
http://www.delorie.com/djgpp/doc/libc/libc_628.html
Its got a list of some 100 conversion characters.
Mayank.
Use %lD (note that the 'l' is small and the 'D' is in caps).
You can refer to:
http://www.delorie.com/djgpp/doc/libc/libc_628.html
Its got a list of some 100 conversion characters.
Mayank.
ASKER
Perfect! =)
On a side note, "%llud" will print the unsigned value.
And "%lD" does NOT work.
On a side note, "%llud" will print the unsigned value.
And "%lD" does NOT work.
According to the 1999 C standard, it should be the second form Zoppo showed, "%lld". However, if your particular compiler does not conform to the standard in this detail, that form may not work and one of the other suggestions may.
--efn
--efn
I didn't try it on my compiler.... anyways, you can check out the site.... it says that it should.
Cheers,
Mayank.
Cheers,
Mayank.