From owner-freebsd-questions Wed Jan 31 19:45:45 2001 Delivered-To: freebsd-questions@freebsd.org Received: from guru.mired.org (okc-65-26-235-186.mmcable.com [65.26.235.186]) by hub.freebsd.org (Postfix) with SMTP id 1369137B491 for ; Wed, 31 Jan 2001 19:45:28 -0800 (PST) Received: (qmail 46115 invoked by uid 100); 1 Feb 2001 03:45:27 -0000 From: Mike Meyer MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <14968.56279.589323.286029@guru.mired.org> Date: Wed, 31 Jan 2001 21:45:27 -0600 (CST) To: lucas@slb.to Cc: questions@freebsd.org Subject: Re: Printf question In-Reply-To: <20010131213515.A12876@billygoat.slb.to> References: <109394@toto.iv> <14968.51016.322465.80746@guru.mired.org> <20010131213515.A12876@billygoat.slb.to> X-Mailer: VM 6.75 under 21.1 (patch 10) "Capitol Reef" XEmacs Lucid X-face: "5Mnwy%?j>IIV\)A=):rjWL~NB2aH[}Yq8Z=u~vJ`"(,&SiLvbbz2W`;h9L,Yg`+vb1>RG% *h+%X^n0EZd>TM8_IB;a8F?(Fb"lw'IgCoyM.[Lg#r\ Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Lucas Bergman types: > > > What you probably want is the `%llu' specifier instead of `%ld'. > > > Note that `long long' is a _very_ recent addition to the C > > > standard, so proceed with caution if you want your program to be > > > portable. > > > > The man page doesn't mention ll as a modifier, but talks about q. I > > get the results he wants with %qd, %qu, or %llu - but not %lld. > > -Wall doesn't complain about either one (on -current, anyway). > > Hrmm? > > roostor % echo 2 ^ 35 | bc > 34359738368 > roostor % cat foo.c > #include > > int > main(void) > { > long long x = 1LL << 35; > printf("%lld\n", x); > return 0; > } > roostor % gcc -Wall foo.c > roostor % ./a.out > 34359738368 If you look at the original code, he was using an unsigned long long. %lld in that case gave different results from %qd, %qu, and %llu. Possibly it's a bug. http://www.mired.org/home/mwm/ Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message