By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,260 Members | 1,340 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,260 IT Pros & Developers. It's quick & easy.

Problem on the range of a data type

P: n/a
Dear All,

Is there any way to get the largest or smallest number of a intrinsic
date type in the c++ code?

Thanks,

Shuisheng

Sep 29 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
shuisheng wrote:
Is there any way to get the largest or smallest number of a intrinsic
date type in the c++ code?
Yes, read about 'std::numeric_limits' template.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Sep 29 '06 #2

P: n/a
"shuisheng" <sh*********@yahoo.comwrote:
Is there any way to get the largest or smallest number of a intrinsic
date type in the c++ code?
Yes...

#include <limits>

using std::numeric_limits;
using std::cout;

int main() {
cout << numeric_limits<int>::min() << '\n';
cout << numeric_limits<int>::max() << '\n';

cout << numeric_limits<double>::min() << '\n';
cout << numeric_limits<double>::max() << '\n';
}

--
There are two things that simply cannot be doubted, logic and perception.
Doubt those, and you no longer*have anyone to discuss your doubts with,
nor any ability to discuss them.
Sep 29 '06 #3

P: n/a
On 29 Sep 2006 10:53:42 -0700 in comp.lang.c++, "shuisheng"
<sh*********@yahoo.comwrote,
>Is there any way to get the largest or smallest number of a intrinsic
date type in the c++ code?
See #include <limits>

Sep 29 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.