Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

40,039 questions

52,004 answers

573 users

How to use numeric limits in C++

1 Answer

0 votes
#include <iostream>
#include <limits>
#include <string>

int main()
{
	std::cout << "max(short): " << std::numeric_limits<short>::max() << std::endl;
	std::cout << "max(int):   " << std::numeric_limits<int>::max() << std::endl;
	std::cout << "max(long):  " << std::numeric_limits<long>::max() << std::endl;
	std::cout << std::endl;

	std::cout << "max(float):       " << std::numeric_limits<float>::max() << std::endl;
	std::cout << "max(double):      " << std::numeric_limits<double>::max() << std::endl;
	std::cout << "max(long double): " << std::numeric_limits<long double>::max() << std::endl;
	std::cout << std::endl;

	std::cout << "is_signed(char): " << std::numeric_limits<char>::is_signed << std::endl;
	std::cout << std::endl;

	return 0;
}

/*
run:

max(short): 32767
max(int):   2147483647
max(long):  2147483647

max(float):       3.40282e+38
max(double):      1.79769e+308
max(long double): 1.79769e+308

is_signed(char): 1

*/

 



answered Nov 25, 2017 by avibootz
...