Vref = 5.12 Vout = 2.06 Vans = 0 for MS in range(16): for LS in range(16): Vans = (MS/16 + LS/256) * 5.12 print Vans