/*
The following program prints the size in bytes of the integral and
floating-point types in C++. It also prints using two methods the 
maximum and the minimum values of some of these data types. 
Finally, the program demenostrates an overflow case in which 
a value larger than the maximum value of type short is stored in 
a variable of type short and then printed.
  */
#include <iostream>
#include <limits>
#include <float.h>


using namespace std;

int main()
{
	cout << "Size in bytes: " << endl;

	cout << "int: " << sizeof(int) << endl;
	cout << "long: " << sizeof(long) << endl;
	cout << "float: " << sizeof(float) << endl;
	cout << "double:" << sizeof(double) << endl;
	cout << "long double:" << sizeof(long double) << endl;

	system("pause");
	cout << "Maxmimum and minimum values using the float header file:" << endl; 
	cout << "Max. float: " << FLT_MIN << endl;
	cout << "Max. float: " << FLT_MAX << endl;
	cout << "Max. double: " << DBL_MAX << endl;
	cout << "Min. double: " << DBL_MIN << endl;
	cout << "Max. double: " << LDBL_MAX << endl;
	cout << "Min. double: " << LDBL_MIN << endl;
	cout << "Min. int: " << INT_MIN << endl;
	cout << "Max. int: " << INT_MAX << endl;
	cout << "Min. short: " << SHRT_MIN << endl;
	cout << "Max. short: " << SHRT_MAX << endl;
	cout << "Min. long: " << LONG_MIN << endl;
	cout << "Max. long: " << LONG_MAX << endl;
	cout << "Min. char: " << CHAR_MIN << endl;
	cout << "Max. char: " << CHAR_MAX << endl;

	system("pause");
	cout << "Maxmimum and minimum values using the limits header file:" << endl; 
	cout << "Max short: " << numeric_limits<short>::max() << endl;
	cout << "Max short: " << numeric_limits<short>::min() << endl;
	cout << "Max int: " << numeric_limits<int>::max() << endl;
	cout << "Max int: " << numeric_limits<int>::min() << endl;
	cout << "Max unsigned short: " << numeric_limits<unsigned short>::max() << endl;
	cout << "Max unsigned short: " << numeric_limits<unsigned short>::min() << endl;
	cout << "Max long: " << numeric_limits<long>::max() << endl;
	cout << "Max long: " << numeric_limits<long>::min() << endl;
	cout << "Max float: " << numeric_limits<float>::max() << endl;
	cout << "Max float: " << numeric_limits<float>::min() << endl;
	cout << "Max double: " << numeric_limits<double>::max() << endl;
	cout << "Max double: " << numeric_limits<double>::min() << endl;
	cout << "Max long double: " << numeric_limits<long double>::max() << endl;
	cout << "Max long double: " << numeric_limits<long double>::min() << endl;
	//cout << a << endl;

	system("pause");

	cout << "Here is what will happen if we try to "
		 << "store in a variable of type short a value "
		 << "larger than the maximum value of type short."
		 << "This is an example on overflow."
		 << endl;
	short a = SHRT_MAX + 10;
	cout << "The value stored is: " << a << endl;
	return 0;
}
