From: buers AT gmx DOT de (Dieter Buerssner) Newsgroups: comp.os.msdos.djgpp Subject: Re: long long in printf() Date: 10 Apr 2000 23:08:08 GMT Lines: 36 Message-ID: <8cttev.3vs6k6b.0@buerssner-17104.user.cis.dfn.de> References: <20000410 DOT 154104 DOT -410679 DOT 5 DOT roberts DOT j DOT whitlock AT juno DOT com> NNTP-Posting-Host: pec-114-72.tnt7.s2.uunet.de (149.225.114.72) Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: fu-berlin.de 955408088 7180298 149.225.114.72 (16 [17104]) X-Posting-Agent: Hamster/1.3.13.0 User-Agent: Xnews/03.02.04 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Robert S Whitlock wrote: >Hello I'm trying to use printf() and family to print long long variables. >But I don't know of any conversion spcifier thingie. Can anyone help me >out? The following code should answer your question. #include int main(void) { long long ll = 0x123456789abcdefLL; unsigned long long ull = 0x123456789abcdefULL; printf("long long ll is %Ld, in hex this is 0x%Lx\n", ll, (unsigned long long)ll); printf("unsigned long long ull is %Lu, in hex this is 0x%Lx\n", ull, ull); return 0; } So, use the "L" modifier for long long type. >If there is another data type that has increased range over the int type >and is a "whole number" variable instead of a floating point, and you >know the conversion specifier to that, that would be great too. There is no other standard integral data type with an increased range. If you are careful, and if you work on a platform, that is conformant to the IEEE floating point standards, type double or type long double might be useful and more portable to non gcc compilers (and to pre-C99 compilers). With type double, all integers up to 2^54 are guaranteed to be exact floating point numbers. -- Regards, Dieter