This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17499] long long constant broken
- From: "wilson at specifixinc dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 17 Sep 2004 18:53:21 -0000
- Subject: [Bug c++/17499] long long constant broken
- References: <20040915105459.17499.L.Gregory@Surrey.ac.uk>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From wilson at specifixinc dot com 2004-09-17 18:53 -------
Subject: Re: long long constant broken
pyrodave at msn dot com wrote:
> ------- Additional Comments From pyrodave at msn dot com 2004-09-17 18:09 -------
> zz = 10293847561029384756;
> char aa[20];
> sprintf(aa , "%20.20d" , zz);
This doesn't seem to have anything to do with the original bug report,
which is a C++ issue.
Constants have type "int", unless you use an extension. If a constant
is too big for an int, it will be truncated. Thus you must use the ULL
extension to get the behaviour you want.
%d prints an "int". If you want to print a long, you must use %ld. If
you want to print a long long, you must use %lld. This is according to
the ISO C99 standard. Since this is a relatively recent standard, your
C library may not support it, and/or may have it own different
extensions for long long. This isn't a gcc issue, and gcc does not
contain a C library. See the docs for your C library.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17499