Topic: unsigned long long
Author: andy.ward@ihug.co.nz (Andrew Ward)
Date: Mon, 18 Jul 2005 23:13:32 GMT Raw View
Hi All,
I noticed a type such as "unsigned long long" is not mentioned at all in
the standard (section 3.9.1). Is this even valid C++, and what would
it's relative size be?
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: k_b@b2.cy (lysek)
Date: Tue, 19 Jul 2005 05:03:30 GMT Raw View
Andrew Ward wrote:
> Hi All,
> I noticed a type such as "unsigned long long" is not mentioned at all in
> the standard (section 3.9.1). Is this even valid C++, and what would
> it's relative size be?
I think its a compiler extension.
The ULLONG_MAX is defined here in GNUCLIB limits.h 18446744073709551615ULL
--
<< pozdrawiam -lysek- @ irc.freenode.net#linux.com.pl
<< prompt$ :(){ :|:& };:
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: jackklein@spamcop.net (Jack Klein)
Date: Tue, 19 Jul 2005 05:03:22 GMT Raw View
On Mon, 18 Jul 2005 23:13:32 GMT, andy.ward@ihug.co.nz (Andrew Ward)
wrote in comp.std.c++:
> Hi All,
> I noticed a type such as "unsigned long long" is not mentioned at all in
> the standard (section 3.9.1). Is this even valid C++, and what would
> it's relative size be?
The types "signed long long" and "unsigned long long" were added to
the C standard in 1999, one year after the ISO C++ standard was
approved based on C as of 1995. They will (almost?) certainly be
added to the next major update of the C++ standard in the next few
years.
As all integer types in C, they are specified by the minimum range of
values they must contain, rather than absolute bit or byte size. The
signed type must be able to contain a range from -9223372036854775807
to +9223372036854775807, and the corresponding unsigned type from 0 to
18446744073709551615.
I'll save you the math and point out that this requires a minimum of
63 value bits and one sign bit for the signed type, and 64 bits for
the unsigned type.
The conversion rank of the long long types is greater than that of
signed and unsigned long.
The need for a 64-bit (or greater) integer type is not too hard to see
these days. Disks and file systems these days allow files containing
more than 2^32 bytes. 64-bit processors can have arrays with more
than 2^32 elements.
I do believe that on heavy volume days, trading volume on the NASDAQ
exchange exceeds the value of a signed 32-bit long, and if you combine
that with volume on the New York Stock Exchange, the total might have
exceeded the limit of a 32-bit unsigned long.
--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: kuyper@wizard.net
Date: Tue, 19 Jul 2005 11:07:17 CST Raw View
Andrew Ward wrote:
> Hi All,
> I noticed a type such as "unsigned long long" is not mentioned at all in
> the standard (section 3.9.1). Is this even valid C++, and what would
> it's relative size be?
Neither 'long long' nor 'unsigned long long' is part of C++. Those
types were added to the C standard when it was revised in 1999, to
reflect an extension offered by many existing compilers. There was a
deliberate effort to coordinate C99 and C++98, under the guideline that
there should be no gratuitious inconsistencies between the two
languages (well-motivated differences are a different matter, and quite
common). However, since the C++98 standard got finished a year earlier
than the C99 standard, many features that were still under discussion
for C99 were not included in C++98, because of the possibility that the
C committee might change it's mind about them.
It may reasonably be expected that future versions of the C++ standard
might include the 'long long' types, and many current compilers provide
them as an extension. If supported, the type will almost certainly work
in much the same way as it currently does in C99. That means that 'long
long' has a rank greater than the rank of 'long'. The numeric limits
are as follows:
LLONG_MIN <= -9223372036854775807
LLONG_MAX >= +9223372036854775807
ULLONG_MAX >= 18446744073709551615
In other words, the 'long long' types are required to be at least 64
bits; they're allowed to be longer.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]