def round_num(n, m):
    if m == 0:
        return 0

    quotient = n / m

    if quotient >= 0:
        rounded_quotient = int(quotient + 0.5)
    else:
        rounded_quotient = int(quotient - 0.5)

    return rounded_quotient * m