I try to convert two byte to float and I have problem with precision. In my case I read temp and store into two bytes. For example 14.69*C - 14(dec) to one byte and 69(dec) to second byte. Then I would like to convert this bytes to float and compare with another float, for example:
byte byte1 = 0xE;
byte byte2 = 0x45;
float temp1 = (float) byte1*1.0 + (float) byte2*0.01; // byte2*0.1 if byte2<10
float temp2 = 14.69;
...
if (temp1==temp2){
...
}
I expected temp1 value 14.69 but value is 14.68999958 - Why, and what is the solution?