subtract previous variable value from current value

Hey guys,
I have 2 variables, angle_x and angle_y, from an accelerometer. I want to subtract the current value of the variable from the previous value of the same variable. I tried this,

int x_initial = angle_x ;
int x_final = x_initial - angle_x

But I am not sure how to make it so angle_x is the previous value, and x_initial is the current value. Any help would be greatly appreciated. Thanks.
SR

static int x_previous = 0;
int x_initial = angle_x ;
int x_final = x_initial - x_previous;
x_previous = angle_x;

Thanks for the reply. That makes sense. I will give it a try.

that sort of worked, now it just resets the value to 0 when not in motion, I want it to keep adding on to the old number.

now it just resets the value to 0 when not in motion

That's arithmetic for you.

SteveRogers:
I want it to keep adding on to the old number.

Perhaps you ought to give some examples of what you're trying to achieve, because 'adding on to the old number' seems to be the exact opposite of what you originally described.