I've just translated some math done in Python to C# which calibrates the temperature reading from a BMP180 Temp/Pressure sensor and it appears to be working! The problem is that I'm not entirely confident it will work all the time or if I have to do some casting in there somewhere. Please take a look and see if you can spot any traps. I'll be amazed if this is fine, C# seems pretty type A when it comes to datatype mixing.
Thanks!
C#:
// _cal_ are of type int
private double ReadTemp()
{
long UT, X1, X2, B5;
double tempC;
UT = ReadRawTemp(); // returns an int
X1 = (((UT - _cal_AC6) * _cal_AC5) >>15);
X2 = ((_cal_MC << 11 ) / (X1 + _cal_MD));
B5 = X1 + X2;
tempC = ((B5 + 8 ) >> 4) / 10d;
return tempC;
}
Thanks!