473,378 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Where max and min int are defined?

Hi,

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

Best wishes,
Peng

Nov 6 '05 #1
5 5803
Pe*******@gmail.com 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.

Nov 6 '05 #2

<Pe*******@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr 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
Nov 6 '05 #3

Josh Mcfarlane wrote:
Pe*******@gmail.com 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?

Nov 6 '05 #4

"Mike Wahler" <mk******@mkwahler.net> wrote in message
news:Yu**************@newsread2.news.pas.earthlink .net...

<Pe*******@gmail.com> wrote in message
news:11**********************@g43g2000cwa.googlegr 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
Nov 6 '05 #5
* Pe*******@gmail.com:

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?
Nov 6 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris | last post by:
This seems inconsistent: #!/usr/bin/perl -w use strict; my @y; if(!defined(@y)) {
5
by: Andy Skypeck | last post by:
I am looking for some validation against a dubious coding practice that prevails where I work. C types defined in types.h (Linux) or stdint.h (Windows, C99?) are used as if they belong to the C++...
2
by: David Emme | last post by:
Access 97 I have a number of SELECT statements which contain references to user-defined VBA functions. These typically work as expected, but occasionally, on one user's machine or another,...
3
by: Leiji Liu | last post by:
Hi, I am curious if there are any pre-defined varables (constants?) in C? I saw some code with __LINE__, __FILE__, etc. Are those located in some include files? LL
2
by: PeteZ | last post by:
what using . . . . statement do I need to get this value (CommandType.StoredProcedure) defined ? even when I have defined the using statements: using System; using System.Data.SqlClient;...
3
by: jdm | last post by:
In the sample code for the SortedList class, I see the use of a string typecasting macro consisting of a single letter "S". i.e.: Sortedlist->Add(S"Keyval one", S"Item one"); Now I have...
39
by: dancer | last post by:
Can somebody tell me why I get this message with the following code? Compiler Error Message: BC30452: Operator '&' is not defined for types 'String' and 'System.Web.UI.WebControls.TextBox'. ...
3
by: allendowney | last post by:
Hi All. In a complex inheritance hierarchy, it is sometimes difficult to find where a method is defined. I thought it might be possible to get this info from the method object itself, but it...
2
by: jmike | last post by:
I'm using some legacy code that has a user-defined exception in it. The top level program includes this line from TestRunError import * It also imports several other modules. These other...
1
by: qwedster | last post by:
Hola! In the following code snippet, I am creating User Defined Function (T-SQL) programmatically into database from C# Code: BTW, this code originally I wrote for creating StoredProcedure...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.