Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ standard library constants for big and small numbers?

Is there a constant in the C++ std lib somewhere that means something like "largest representable number" and "smallest representable number"? In Matlab, we have things like EPS, realmax, and realmin. I was wondering if there was an equivalent for C++.

like image 542
Fadecomic Avatar asked Nov 17 '25 14:11

Fadecomic


1 Answers

In the limits header you can find a templatized function for max and min,

std::numeric_limits<TYPE>::max();
std::numeric_limits<TYPE>::min();

Here is some reference: http://www.cplusplus.com/reference/std/limits/numeric_limits/

like image 57
Connor Hollis Avatar answered Nov 19 '25 03:11

Connor Hollis



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!