Commit 4be7bb46 authored by Antoine Millet's avatar Antoine Millet Committed by Sébastien Luttringer
Browse files

Implemented negative values on si tagdisplay

parent 949e4f0e
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -138,14 +138,22 @@ class TagDisplay(object):

    def type_bit(self, value):
        '''Bit type'''
        if value.isdecimal():
            v = float(value)
        if value.startswith('-'):
            value_without_minus = value[1:]
            neg = True
        else:
            value_without_minus = value
            neg = False
        if value_without_minus.isdecimal():
            v = float(value_without_minus)
            if v >= 1000:
                si = "KMGTPEZY"
                p = min(math.floor(math.log(abs(v), 2)/10.0), pow(2, len(si)))
                d = v / pow(2, 10*p)
                u = si[int(p-1)]
                value =  u"%.4g%si"%(d, u)
                if neg:
                    value =  u"-" + value
        return value

    def type_second(self, value):