Machine Limits

A small c++ example which prints out the limits of some basic data types
in the pc that is run to.




#include <iostream>
#include 	<limits>
using namespace std;

int main() {
	cout<<"------------------------------------------------------------------------"<<endl;
	cout<<"This code outputs the numerical limits of your machine"<<endl;

	cout<<"------------------------------------------------------------------------"<<endl;
	cout<<"The smallest float is=  "<<numeric_limits<float>::min() <<endl;
	cout<<"The largest float is=  "<<numeric_limits<float>::max() <<endl;
	cout<<"The smallest float non-zero number:"<<numeric_limits<float>::epsilon()<<endl;

	cout<<"The base of exponent-float:"<<numeric_limits<float>::radix<<endl;
	cout<<"Infinity in float:"<<numeric_limits<float>::infinity()<<endl;
	cout<<"------------------------------------------------------------------------"<<endl;

	cout<<"The smallest double is=  "<<numeric_limits<double>::min() <<endl;
	cout<<"The largest double is=  "<<numeric_limits<double>::max() <<endl;
	cout<<"The base of exponent-double:"<<numeric_limits<double>::radix<<endl;
	cout<<"Infinity in double:"<<numeric_limits<double>::infinity()<<endl;
	cout<<"The smallest double non-zero number:"<<numeric_limits<double>::epsilon()<<endl;

	cout<<"------------------------------------------------------------------------"<<endl;
	cout<<"The smallest long double is=  "<<numeric_limits<long double>::max() <<endl;
	cout<<"The largest long double is=  "<<numeric_limits<long double>::max() <<endl;
	cout<<"The smallest long double non-zero number:"<<numeric_limits<long double>::epsilon()<<endl;

	cout<<"------------------------------------------------------------------------"<<endl;
	cout<<"Number of binary digits-mantissa:"<<numeric_limits<float>::digits<<endl;
	cout<<"Number of decimal digits-mantissa:"<<numeric_limits<float>::digits10<<endl;

}