I forgot how to program over the years.
I want to cast floats that this sensor outputs into a variable type that would store temperature as 99.99 and humidity as percent in the similar fashion. How do I accomplish this?
I want to smooth data and this seems to be a very memory efficient way to do this.
I want to cast floats that this sensor outputs into a variable type that would store temperature as 99.99 and humidity as percent in the similar fashion.
Cast them to a float. Oh, wait. What's the purpose? A float is the ONLY data type that can store a non-integral type.
Two Decimal place precision!!! and number bust be smaller than 327.67 (for int data type)
for larger numbers with or more decimal places use "long" data type to get max number saved 21,474,836.47
try multiplying by 100 moving the decimal point over!
//
float MyFloat = 99.99999
// to prep for saving
int StoreageInt = (int) MyFloat * 100;
//to retrieve the float:
float MySavedFloat = (float) StoreageInt * .01;
// MySavedFloat will == 99.99
you loose some of the precision but it stores as an integer