Reputation: 1
I am new to C and Cooja, currently using data type float to store values read from a lighting mote. It would require calculating a basic standard deviation, which would involve a large float value power 2 through powf()
or pow()
or manually multiplying the value by twice. The results would mostly be incorrect and sometimes even appearing in negative. And some results reached a threshold of 32767, in which after I researched on this issue, might point to the issue of data type, where floats with storage size of 2 bytes only support a value range from -32767.0 to +32767.0 and if a value exceeds it will be equivalent to the max value or even go on a cycle for all value range.
Hence, I tried to change all the data types from float to a larger double type with 8 bytes, but it still remains the same incorrect results. Results are printed out using int representation workaround for float values. Is this a data type storage issue, or wrong function used, or these type of large calculations shouldn't be done on single motes? I apologize if the question is quite low-level or stupid. Thank you very much!
Upvotes: 0
Views: 124