def nint(a):
    """return the nearest integer to a."""
    i = int(a)
    if a > 0:
        if a - i > 0.5:
            i += 1
    elif a < 0:
        if a - i < -0.5:
            i -= 1
    return i
