Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Where max and min int are defined?

Reply
Thread Tools

Where max and min int are defined?

 
 
PengYu.UT@gmail.com
Guest
Posts: n/a
 
      11-06-2005
Hi,

Would you please let me know where max and min int are defined in C++?

Best wishes,
Peng

 
Reply With Quote
 
 
 
 
Josh Mcfarlane
Guest
Posts: n/a
 
      11-06-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hi,
>
> Would you please let me know where max and min int are defined in C++?
>
> Best wishes,
> Peng


I believe it's compiler dependent, as on a certain 32-bit compiler, int
may be 4 bytes, but on a certain 64-bit compiler, int may be 8 bytes.

 
Reply With Quote
 
 
 
 
Mike Wahler
Guest
Posts: n/a
 
      11-06-2005

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> Hi,
>
> Would you please let me know where max and min int are defined in C++?


They are *declared* by the standard header <algorithm>.
Where they are *defined* is implementation-dependent.
(Although in all cases I've seen, the definitions themselves
are in the header, so serve as the declarations)

A good C++ book can answer this type of question. IMO
the best one specifically about the standard library
is: www.josuttis.com/libbook


-Mike


 
Reply With Quote
 
PengYu.UT@gmail.com
Guest
Posts: n/a
 
      11-06-2005

Josh Mcfarlane wrote:
> (E-Mail Removed) wrote:
> > Hi,
> >
> > Would you please let me know where max and min int are defined in C++?
> >
> > Best wishes,
> > Peng

>
> I believe it's compiler dependent, as on a certain 32-bit compiler, int
> may be 4 bytes, but on a certain 64-bit compiler, int may be 8 bytes.


Do you mean platform dependent? Do you know where MAX_INT and MIN_INT
are defined in GCC?

 
Reply With Quote
 
Mike Wahler
Guest
Posts: n/a
 
      11-06-2005

"Mike Wahler" <(E-Mail Removed)> wrote in message
news:Yuubf.678$(E-Mail Removed) .net...
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
>> Hi,
>>
>> Would you please let me know where max and min int are defined in C++?

>
> They are *declared* by the standard header <algorithm>.
> Where they are *defined* is implementation-dependent.
> (Although in all cases I've seen, the definitions themselves
> are in the header, so serve as the declarations)
>
> A good C++ book can answer this type of question. IMO
> the best one specifically about the standard library
> is: www.josuttis.com/libbook


After reading another reply, I see I may have misunderstood
you. I thought you were asking about the functions 'min()'
and 'max()'.

There are two places where the (implementation-define)
minimum and maximum values for type 'int' are found:

1) The values returned by functions:
std::numeric_limits<int>::min()
std::numeric_limits<int>::max()
(these are declared by header <limits>

2) The values of the macros INT_MIN and INT_MAX,
declared by header <limits.h> or <climits>

-Mike


 
Reply With Quote
 
Alf P. Steinbach
Guest
Posts: n/a
 
      11-06-2005
* (E-Mail Removed):
>
> Would you please let me know where max and min int are defined in C++?


If you're asking for maximum and minimum values of 'int' type, then you
have a choice of INT_MIN and INT_MAX constants from <climits>, or
std::numeric_limits<int>::min() and std::numeric_limits<int>::max()
functions from <limits>. The latter can be used in template code.

If you're asking for function to compute min and max of two 'int'
values, then that's std::min() and std::max() from <algorithm>.


--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to write min(a,b) instead of Math.min(a,b) juergen Java 3 09-20-2006 04:20 AM
CSS min-width, max-width, and min-height with display:inline Lois HTML 1 12-27-2004 03:03 AM
Converting hrs and min to just min carmen ASP General 4 08-10-2004 08:31 PM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM
dirty stuff: f(int,int) cast to f(struct{int,int}) Schnoffos C Programming 2 06-27-2003 03:13 AM



Advertisments