(Note: I found this but do not yet have source: More precise calcs)

The examples in the data sheet assume an incorrect C operartor order.

Also in Arduino kits the int is a short and a long is a 32 bit int.

On my processor ( LM3S1607 ) an int is 32 bits.

So in this code everything is an int or unsigned int. Never short or unsigned short.

Also Arduino example code assumes the oversampling to be 0 and here we can set it to higher resolution.

The b3 = ... is where parenthesis are needed to get it right.

Enjoy.

int x1, x2, x3, b3, b5, b6, p;

unsigned int b4, b7;

```
x1 = ((BaroState.rawTemperature - Baro_ac6) * Baro_ac5) >> 15;
x2 = (Baro_mc << b5 =" x1" temperaturetenthc =" (b5">> 4;
b6 = b5 - 4000;
x1 = (Baro_b2 * (b6 * b6 >> 12)) >> 11;
x2 = Baro_ac2 * b6 >> 11;
x3 = x1 + x2;
// Error in the BMP085 spec sheet math. Extra parens needed at the V's
// V V
b3 = (((Baro_ac1 * 4 + x3) << Baro_oss) + 2) >> 2;
x1 = Baro_ac3 * b6 >> 13;
x2 = (Baro_b1 * (b6 * b6 >> 12)) >> 16;
x3 = ((x1 + x2) + 2) >> 2;
b4 = (Baro_ac4 * (x3 + 32768)) >> 15;
b7 = (BaroState.rawPressure - b3) * (50000 >> Baro_oss);
p = b7 < x1 =" (p">> 8) * (p >> 8);
x1 = (x1 * 3038) >> 16;
x2 = (-7357 * p) >> 16;
BaroState.pressurePa = p + ((x1 + x2 + 3791) >> 4);
NavState.baro = BaroState.pressurePa;
```