Is there a smaller variable type than float that supports decimal? I am looking for the smallest variable to have the precision of xx.xxx (00.000 - 99.999)
Float and double are the same on Spark.
You could use a 32-bit unsigned integer so that 99999. means 99.999 scaled by 1000. You just have to present it to the user eventually in a scaled fashion.
That is a lot of precision for a real-world value–maybe you could get by with less? Dropping one significant digit would let you use uint16_t scaled by 100.
I am clocking response time of a shooter on an obstacle course. They could take up to 30 seconds to finish the coarse and we want the response times to be in milliseconds.
So I would use the difference between two calls to micros() which returns an unsigned long (uint32_t) type.
% and the integer divide operator
/ to get the fractional and integer parts.
You are right! I just checked sizeof() and floats are 4 bytes and doubles are 8 bytes.
I stand corrected–thank you!