I'm not entirely sure if this is the most elegant way to model things, but here's how integer numbers are represented in a computer:
Let's take an integer variable $x \in \mathbb{Z}$ with $L \leq x \leq U$ and $L \geq 0$, meaning $x$ is non-negative. By using $M$ binary variables (bits) $b_0, \ldots, b_{M-1}$, we can represent $x$ in base 2 as:
$$x = (b_{M-1}b_{M-2}\ldots b_{0})_2 = \sum_{j=0}^{M-1} b_j \cdot 2^j.$$
To minimize the number of binary variables needed, we find the smallest $M$ such that:
$$U \leq \max_{b_0,\ldots,b_{M-1}} \sum_{j=0}^{M-1} b_j \cdot 2^j = \sum_{j=0}^{M-1} 1 \cdot 2^j = 2^{M} - 1,$$
which gives us $M = \left\lceil \log_2{(U + 1)} \right\rceil$. If $L < 0$, the two's complement representation can be used. It is expressed as:
$$x = (b_{M-1}b_{M-2}\ldots b_{0})_2 = -b_{M-1} \cdot 2^{M-1} + \sum_{j=0}^{M-2} b_j \cdot 2^j,$$
where $M = \left \lceil \log_2{( \max \{ |L|, |U| \} + 1)} + 1\right \rceil$ represents the minimum number of binary variables needed to represent $x$.