You are overthinking it a little. By casting an int to a float, and dividing it by 10, the decimal will be preserved:
float degrees;
int degreesTimesTen;
degreesTimesTen = 235;
degrees = (float)degreesTimesTen/10;
// degrees is equal to 23.5
Question
I have an integer which is the temperature with one decimal, multiplied by 10. For example: the integer of 235 should become a float of 23.5. How do I put this into a float?
I know I can get the number before the decimal point by doing int/10 and the decimal by int%10. Could I combine these two values into one floating point number?
Solution
You are overthinking it a little. By casting an int to a float, and dividing it by 10, the decimal will be preserved:
float degrees;
int degreesTimesTen;
degreesTimesTen = 235;
degrees = (float)degreesTimesTen/10;
// degrees is equal to 23.5