What is std::numeric_limits<T>::digits supposed to represent?

Tags: c++ c++11 std c++14

I am writing an integer-like class that represents a value that lies somewhere in a range. For instance, the value of bounded::integer<0, 10> is somewhere in the range [0, 10]. For this class, I have defined radix to be 2.

What should the value of digits be for bounded::integer<-100, 5>?

What about bounded::integer<16, 19>?


You are over-thinking it. There are two simple options for digits specializations for your own ranged_integer

  • log2(Last-First) when you are representing the range [First, Last).
  • the value of N * numeric_limits

This video can help you solving your question :)
By: admin