'Convert value to a string.
The resulting string will contain between (min, max) number of
significant digits.'

def _format_sigdig(self, value, min, max):

    (a, b) = split_number(value)
    ndecimals = len(a)
    if ((a == '0') and (b != '')):
        ndecimals = 0
        while b.startswith('0'):
            b = b[1:]
            ndecimals -= 1
    (a, b) = split_number(bankersround(value, (max - ndecimals)))
    digits = len((a + b).lstrip('0'))
    if (not digits):
        digits = 1
    if ((len(a) >= max) and (a != '0')):
        return a
    if (digits < min):
        b += ('0' * (min - digits))
    if b:
        return ('%s.%s' % (a, b))
    return a
