Mail Archives: djgpp/2000/04/10/19:05:18

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: <>
References: <20000410 DOT 154104 DOT -410679 DOT 5 DOT roberts DOT j DOT whitlock AT juno DOT com>
NNTP-Posting-Host: (
Mime-Version: 1.0
X-Trace: 955408088 7180298 (16 [17104])
X-Posting-Agent: Hamster/
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

The following code should answer your question.

#include <stdio.h>

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

- Raw text -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019