I wrote this code in CodeVision for a Mega128, but when I attempt to print it, all I get is "2f". Let's assume all the math conversions are correct, I've triple-checked them in Excel and on my calculator. This code also runs fine on x86. Is this simply a matter of the Mega128 choking on floating point math, or am I (as usual) doing something dumb?
unsigned char btemp; btemp = 0x5D; btemp = 0xA5; btemp = 0x1A; btemp = '\0'; float btempf; float vbtemp; float rbtemp; float tbtemp; //bitwise op to create decimal rep of hex char array btempf = (btemp << 16) | (btemp << 8) | btemp; //convert from counts to volts, to resistance, to temperature vbtemp = (4.096 / 16777216) * btempf; rbtemp = 11.501 * vbtemp * vbtemp - 160.12 * vbtemp + 1302.8; tbtemp = 0.2564 * rbtemp - 256.19; printf("%.2f", tbtemp); // Print out temperature