def round_margin(margin: float, threshold: float) -> int:
    """Round margin according to threshold

    :param margin: calculated margin
    :param threshold: threshold for rounding
    :return: rounded margin
    """
    root = int(margin)
    if threshold < margin - root:
        return root + 1
    else:
        return root