def reverse_digit(x):
    """
    Reverses the digits of an integer.
    
    Parameters
    ----------
    x : int
        Digit to be reversed.
    
    Returns
    -------
    rev_x : int
        `x` with it's digits reversed.
    """
    
    # Initialisations
    if x < 0:
        neg = True
    else:
        neg = False
    x = abs(x)
    x_len = len(str(x)) # Number of digits in `x`
    rev_x = 0
    
    for i in range(x_len):
        digit = x % 10
        x = x // 10
        
        rev_x += digit*(10**(x_len-i-1))
        
    if neg == True:
        rev_x = -1*rev_x
        return rev_x
    else:    
        return rev_x