def base10tobase2(value, zfill=0):
    """
    This function converts from base 10 to base 2 in string format.  In
    addition, it takes a parameter for zero filling to pad out to a specific
    length.

    Note that the incoming number is converted to an int, and that if it is
    a negative number that the negative sign is added on to the total length,
    resulting in a string 1 char longer than the zfill specified.

    """
    new_value = []
    val = int(value)
    if val < 0:
        neg = True
        val *= -1
    else:
        neg = False
    if val == 0:
        new_value = ['0']
    while val > 0:
        new_value.append(str(val % 2))
        val = val / 2
    new_value.reverse()
    new_value_str = ''.join(new_value)
    if zfill:
        if len(new_value_str) > zfill:
            raise ValueError(
                """
            Base 2 version of %s is longer, %s, than the zfill limit, %s
            """
                 % (value, new_value_str, zfill))
        else:
            new_value_str = new_value_str.zfill(zfill)
    if neg:
        new_value_str = '-' + new_value_str
    return new_value_str
