Date: Mon, 28 Jul 2003 18:47:01 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: djgpp AT delorie DOT com Message-Id: <7458-Mon28Jul2003184701+0300-eliz@elta.co.il> X-Mailer: emacs 21.3.50 (via feedmail 8 I) and Blat ver 1.8.9 In-reply-to: (nospam@aol.com) Subject: Re: integer overflow References: <3F246120 DOT 63C3753C AT worldnet DOT att DOT net> <3F24AA4B DOT 589D3482 AT worldnet DOT att DOT net> Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > From: "News Reader" > Newsgroups: comp.os.msdos.djgpp > Date: Mon, 28 Jul 2003 16:44:36 +0200 > > According to my DJGPP documentation (C-library, HTML) > the format string "%U" instead of "%lu" should work, > but it doesn't. How do you mean ``doesn't work''? What exactly did you expect and what did you see (a short test program and sample output would be nice)? Here's my test program: #include int main (int argc, char *argv[]) { unsigned long k = argc * 3000000000LU; printf ("num: %U %ld\n", k, k); return 0; } and its output when invoked with no arguments (i.e. argc = 1): num: 3000000000 -1294967296 As you see, printing with %U succeeds while %ld tries to interpret the unsigned value as signed and overflows. The only problem with %U that I see is that it is non-standard, so "gcc -Wall" rightfully complains about it. But the program works nonetheless.