C++ reminder #2

One of my favourites in the standard library: numeric_limits. Sometimes, you want to initialize a number to something really big. Some code just uses magic numbers, but the proper way is to use numeric_limits<T>::max(), which does exactly what you expect.

Now numeric_limits<T>::infinity() is funnier. What happens when T is int?

For C++ integers, infinity is 0.

2 thoughts on “C++ reminder #2”

Leave a Reply

Your email address will not be published. Required fields are marked *