On Sun, 20 Apr 2008 18:03:28 +0200, Jean Delvare wrote: > This conversion function should return the following depending on the > resolution: > > 9-bit: ((temp +/- 250) / 500) << 7 > 10-bit: ((temp +/- 125) / 250) << 6 > 11-bit: ((temp +/- 62) / 125) << 5 > 12-bit: ((temp +/- 31) / 62) << 4 Oops, this last one is of course not correct. This should read, for example: 12-bit: ((temp * 2 +/- 62) / 125) << 4 So we might as well write the above: 9-bit: (( temp +/- 250) / 500) << 7 10-bit: (((temp << 1) +/- 250) / 500) << 6 11-bit: (((temp << 2) +/- 250) / 500) << 5 12-bit: (((temp << 3) +/- 250) / 500) << 4 which is easier to generalize. -- Jean Delvare