from typing import Optional


def binstr(num: int, width: Optional[int] = None) -> str:
    """ Returns the binary representation of an integer.

    Parameters
    ----------
    num : int
        The number to convert.
    width: int, optional
        Minimum number of digits used. The default is the global value `BITS`.

    Returns
    -------
    binstr : str
    """
    fill = width or 0
    return f"{num:0{fill}b}"