storing a previously read

hey, does anyone know how to store a previously for example i want to run a loop where and then i want to say if the new = the previous do nothing. or if the new val is different from the previous val than i would want to find the difference... any help would be great...

Is this what you are looking for?

void loop() 
  char val, oldval;
  if ( Serial.available()) {
    if(val != oldval){
        char difference = oldval - val;

Note that the value of difference will be meaningless the first time through because oldval has not been read yet.

If you are looking for something more complicated, have a dig around for the Atmel application note avr135, although primarily about PWM, the source code example uses a queue that can be implemented to store any number of values.