This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/17499] long long constant broken


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]