Date: Wed, 31 Jan 2001 21:45:27 -0600 (CST) From: Mike Meyer <mwm@mired.org> To: lucas@slb.to Cc: questions@freebsd.org Subject: Re: Printf question Message-ID: <14968.56279.589323.286029@guru.mired.org> In-Reply-To: <20010131213515.A12876@billygoat.slb.to> References: <109394@toto.iv> <14968.51016.322465.80746@guru.mired.org> <20010131213515.A12876@billygoat.slb.to>
next in thread | previous in thread | raw e-mail | index | archive | help
Lucas Bergman <lucas@slb.to> 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 <stdio.h> > > 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. <mike -- Mike Meyer <mwm@mired.org> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?14968.56279.589323.286029>