Working with floating point in TinyOS
There are two ways to represent float in nesc. One way, is to do it through by convention using the exponent and mantissa, where you need to use 2^exponent. The function that does that is called powf(). The problem with using that function is that it is reaaaaallly slow. [QUOTE] ----8 DbgOut_P20_ON; r = logf((float)v / 10000.0); // takes up about 10 ms (!!) DbgOut_P20_OFF; ----8 and a ----8 DbgOut_P20_ON; r = powf (10,(float)v / 10000.0); // takes up about 32 ms (!!!!!!) DbgOut_P20_OFF; ----8 [/QUOTE] In case you need to have fast response, this function might not be your choice. One way to optimize the speed of those operations are: "I'd like to mention that pow (a,b) is MUCH harder to implement than exp(b). Use the latter whenever possible. In particular, if a is fixed, use exp(b * log(a)) rather than pow (a,b). ( In fact, that's a common low-precision implementation technique even when a is not fixed.) Also note that keeping ...