I'm reading 3-byte numbers from a file and they are signed (+8 to 
-8million).  This seems to work, but I'm not sure it's right.

# Convert the 3-characters into a number.
    Value1, Value2, Value3 = unpack(">BBB", Buffer[s:s+3])
    Value = (Value1*65536)+(Value2*256)+Value3
        if Value >= 0x800000:
            Value -= 0x1000000
    print Value

For example:
16682720 = -94496

Should it be Value -= 0x1000001 so that I get -94497, instead?

Thanks!

Bob

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to