I'm having trouble getting a function to work right. it's been bugging me badly.. I have a crystalfontz 633 lcd display connected to the serial port with a dallas one wire temperature sensor connected to the display. it sends a temperature report back to the computer once every second. the ConvertTempReport function is used to decode the sensor's output and return it as degrees fahrenheit. if I use printf inside the function, it works perfectly. but I want it to return the temperature as the functions output. when I do that, it gives me weird numbers. I can't figure out why it's doing that or what I'm doing wrong. someone please help. I'm running centos 5 server.

Code:
while(1){
  usleep(100000);  // 1/10 second
  if(check_for_packet()){
  //Terminate the incoming data so C handles it well in case it is a string.
  incoming_response.data[incoming_response.data_length]=0;

  double tempf;
  tempf=ConvertTempReport(incoming_response.data);
  printf("%f\n",tempf);

  }
}


double ConvertTempReport(ubyte data[4]){
  double temp;
  temp=((data[2] << 8) | data[1])/16.0;
  if(temp!=0){temp=(1.8 * temp)+32.0;}
  return temp;
}


this is the output:

14336.000000
12320.000000
10272.000000
8224.000000
6176.000000
4128.000000
19809.000000
17761.000000
32097.000000
30049.000000
28001.000000
25953.000000