Hi, I am a programming novice, I'm trying to convert a FLOAT to an INT for transmission over wireless, then want to convert the INT back to the original FLOAT value. I thought this would work:
float temp = 23.54;
int int_temp = (temp * 100);
float converted_temp= int_temp / 100;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.print("temp: "); Serial.print(temp);
Serial.print("\nmultiplied: "); Serial.print(int_temp);
Serial.print("\nconverted: "); Serial.println(converted_temp);
}
void loop() {
// put your main code here, to run repeatedly:
}
... but I get the following output, note the loss of information to the right of the decimal point:
temp: 23.54
multiplied: 2354
converted: 23.[color=limegreen]00[/color]
I'm sure its an easy one but I can't find a solution.
Thanks
Jon