Topic: minimum maxima" for fundamental types


Author: Fritz Bosch <FBosch@alcatel.de>
Date: 1998/10/14
Raw View
devphil@my-dejanews.com
wrote:
>
> [Cc'd to poster]
>
> In article <3619CE5F.CAFFE468@alcatel.de>,
>   Fritz Bosch <FBosch@alcatel.de> wrote:
> >
> > The ISO C standard defines "minimum maxima" for the values values of
> > fundamental types, e.g.:
> >
> >   int:          -32767       to  32767
> >   unsigned int:  0           to  65535
> >   long:         -2147483647  to  2147483647
> >
> > The C++ standard (actually the Public Review Document) is not that
> > specific:
> [3.9.1]/2
> >   2 There are four signed integer types: "signed char", "short int",
> >     "int", and "long int." In this list, each type provides at least as
> >     much storage as those preceding it in the list. Plain ints have the
> >     natural size suggested by the architecture of the execution
> >     environment; the other signed integer types are provided to meet
>                   ^
>                   ^
>                   ^
>
> The footnote at this point in the published Standard adds, "that is,
> large enough to contain any value in the range of INT_MIN and INT_MAX,
> as defined in the header <climits>."
>
> So there are /some/ minimum and maximum values for int given, beyond
> the normative reference to the C Standard; you just have to use the
> preprocessor and/or numeric_limits<> to see what they are.  :-)  I
> suspect that the "hardcoded" ISO C requirements are a little outdated;

These mechanisms supply the minimum and maximum values for your
particular C++ implementation.  When you (attempt to) write portable
code, you need to know the ranges guaranteed/required ("hardcoded") by
your standard for all implementations - i.e.  "minimum maxima".

---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: Fritz Bosch <FBosch@alcatel.de>
Date: 1998/10/06
Raw View
The ISO C standard defines "minimum maxima" for the values values of
fundamental types, e.g.:

  int:          -32767       to  32767
  unsigned int:  0           to  65535
  long:         -2147483647  to  2147483647

The C++ standard (actually the Public Review Document) is not that
specific:

  3.9.1  Fundamental types

   ...

  2 There are four signed integer types: "signed char", "short int",
    "int", and "long int." In this list, each type provides at least as
    much storage as those preceding it in the list. Plain ints have the
    natural size suggested by the architecture of the execution
    environment; the other signed integer types are provided to meet
    special needs.

It does, however, quote the C standard as a normative reference.

Does this mean that the minimum maxima defined for C also
hold for C++?

Thanks

Fritz


[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: "Paul D. DeRocco" <pderocco@ix.netcom.com>
Date: 1998/10/08
Raw View
Fritz Bosch wrote:
>
> The ISO C standard defines "minimum maxima" for the values values of
> fundamental types, e.g.:
>
>   int:          -32767       to  32767
>   unsigned int:  0           to  65535
>   long:         -2147483647  to  2147483647
>
> The C++ standard (actually the Public Review Document) is not that
> specific:
[snip]
> It does, however, quote the C standard as a normative reference.
>
> Does this mean that the minimum maxima defined for C also
> hold for C++?



Author: jackklein@worldnet.att.net (Jack Klein)
Date: 1998/10/08
Raw View
On 6 Oct 1998 17:12:59 GMT, Fritz Bosch <FBosch@alcatel.de> wrote:

>
> The ISO C standard defines "minimum maxima" for the values values of
> fundamental types, e.g.:
>
>   int:          -32767       to  32767
>   unsigned int:  0           to  65535
>   long:         -2147483647  to  2147483647
>
> The C++ standard (actually the Public Review Document) is not that
> specific:
>
>   3.9.1  Fundamental types
>
>    ...
>
>   2 There are four signed integer types: "signed char", "short int",
>     "int", and "long int." In this list, each type provides at least as
>     much storage as those preceding it in the list. Plain ints have the
>     natural size suggested by the architecture of the execution
>     environment; the other signed integer types are provided to meet
>     special needs.
>
> It does, however, quote the C standard as a normative reference.
>
> Does this mean that the minimum maxima defined for C also
> hold for C++?
>
> Thanks
>
> Fritz
>

<Jack>

Yes it does.  Section 18.2.2 of the final standard (C Library) states that the
contents of the header climits are the same as the standard C library header
limits.h.  In the absence of any specification to the contrary that would
impose the same requirements on the limits it contains.

</Jack>
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: devphil@my-dejanews.com
Date: 1998/10/08
Raw View
[Cc'd to poster]

In article <3619CE5F.CAFFE468@alcatel.de>,
  Fritz Bosch <FBosch@alcatel.de> wrote:
>
> The ISO C standard defines "minimum maxima" for the values values of
> fundamental types, e.g.:
>
>   int:          -32767       to  32767
>   unsigned int:  0           to  65535
>   long:         -2147483647  to  2147483647
>
> The C++ standard (actually the Public Review Document) is not that
> specific:
[3.9.1]/2
>   2 There are four signed integer types: "signed char", "short int",
>     "int", and "long int." In this list, each type provides at least as
>     much storage as those preceding it in the list. Plain ints have the
>     natural size suggested by the architecture of the execution
>     environment; the other signed integer types are provided to meet
                  ^
                  ^
                  ^

The footnote at this point in the published Standard adds, "that is,
large enough to contain any value in the range of INT_MIN and INT_MAX,
as defined in the header <climits>."

So there are /some/ minimum and maximum values for int given, beyond
the normative reference to the C Standard; you just have to use the
preprocessor and/or numeric_limits<> to see what they are.  :-)  I
suspect that the "hardcoded" ISO C requirements are a little outdated;
a quick grep on an older-but-still-useful platform gives me this for
'int' and 'unsigned int':

    [monkey 115]> grep INT_MIN /usr/include/limits.h
    #define INT_MIN         (-2147483647-1)
    [monkey 116]> grep INT_MAX /usr/include/limits.h
    #define INT_MAX         2147483647
    #define UINT_MAX        4294967295U
    [monkey 117]>

Which is a little bit beyond the 65536-range...


Luck++;
/dev/phil

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]