Trouble understanding BMP180 code

Hi guys
So usually when you want to define an integer its as easy as int height = 0; but take a look at this, i know im doing something wrong but i cant find a solution

#include <SFE_BMP180.h>
#include <Wire.h>
SFE_BMP180 pressure;
#define ALTITUDE 1667.0
int oldpress = 0 ;

void setup()

{
Serial.begin(9600);
Serial.println("REBOOT");
// Initialize the sensor (it is important to get calibration values stored on the device).
if (pressure.begin())
Serial.println("BMP180 init success");
else
{
// Oops, something went wrong, this is usually a connection problem,
// see the comments at the top of this sketch for the proper connections.

Serial.println("BMP180 init fail\n\n");
while(1); // Pause forever.
}
pinMode(4, OUTPUT);

}

void loop()
{
char status;
double T,P,p0,a;

status = pressure.startPressure(3);
if (status != 0)
{
// Wait for the measurement to complete:
delay(status);

status = pressure.getPressure(P,T);
if (status != 0)
{
// Print out the measurement:
Serial.print("absolute pressure HPA : ");
Serial.print(P*10);
Serial.println(" hpa, ");

oldPress = (P);

if (pressure.startPressure(3) < P )
{
//digitalWrite(4, HIGH);
}

delay(100);
}
else Serial.println("error retrieving pressure measurement\n");
}
else Serial.println("error starting pressure measurement\n");
}

take a look at oldPress = (P); , how do i get that P value that gets printed into the oldPress int ?

So what actual problem are you seeing?

It should be o.k. but you don't need the brackets. oldPress = P; is more normal. But casting a double (float) into an int may or may not give you what you're expecting.

And I hate programs that are full of single character variable names making it impossible to work out or remember what on earth they're supposed to mean.

Steve

how do i get that P value that gets printed into the oldPress int ?

Do you want P or P*10 (the value that is printed) in the oldPress variable ?

You are copying the integer part of 'P' into 'oldpress' and then not using 'oldpress' for anything. What did you want to do with 'oldpress'?

The parentheses around 'P' are not needed. oldpress = P; is sufficient to copy the integer part of 'P' into 'oldpress'.