These are the same:
Code:
cout << numeric_limits<char>::min();
cout << '\0';What would you expect to see?
If you want to see an integer value, cast to an int.
gg
Not sure if we're on same page
Idea is to extract lower and upper bounds on `char' for this machine in a representation-independent way.
I was expecting to see
smallest char == 0
largest char == 255
for an ANSI-compliant implementation.
Here's the rest:
Code:
#include <iostream>
using namespace std;
#include <limits>
int main() {
cout << "smallest char ==" << numeric_limits<char>::min() << '\n' // Not behaving like others
<< "largest char ==" << numeric_limits<char>::max() << '\n' // Not behaving like others
<< "smallest short ==" << numeric_limits<short>::min() << '\n'
<< "largest short ==" << numeric_limits<short>::max() << '\n'
<< "smallest int ==" << numeric_limits<int>::min() << '\n'
<< "largest int ==" << numeric_limits<int>::max() << '\n'
<< "smallest long ==" << numeric_limits<long>::min() << '\n'
<< "largest long ==" << numeric_limits<long>::max() << '\n'
<< "smallest float ==" << numeric_limits<float>::min() << '\n'
<< "largest float ==" << numeric_limits<float>::max() << '\n'
<< "smallest double ==" << numeric_limits<double>::min() << '\n'
<< "largest double ==" << numeric_limits<double>::max() << '\n'
<< "smallest long double ==" << numeric_limits<long double>::min() << '\n'
<< "largest long double ==" << numeric_limits<long double>::max() << '\n'
<< "smallest unsigned ==" << numeric_limits<unsigned>::min() << '\n'
<< "largest unsigned ==" << numeric_limits<unsigned>::max() << '\n';
}
Output:
Code:
smallest char ==
largest char =
smallest short ==-32768
largest short ==32767
smallest int ==-2147483648
largest int ==2147483647
smallest long ==-2147483648
largest long ==2147483647
smallest float ==1.17549e-38
largest float ==3.40282e+38
smallest double ==2.22507e-308
largest double ==1.79769e+308
smallest long double ==3.3621e-4932
largest long double ==1.18973e+4932
smallest unsigned ==0
largest unsigned ==4294967295