Hello,

On the MSP430, all floating points types are 32 bit.
A cast from int64_t to float produces strange results:
Negative values are rounded to multiples of -256 (tested for -10000 to 0)
Positive numbers smaller than 8725651e09 (8.7e15) are converted correctly,
tested at 0.1% intervals. Above this number, it sometimes, but not always,
goes wrong by many orders of magnitude. Example:
8725651e09 casts to 8725651e09 (OK)
8725738e09 casts to 837068800  (extremely wrong)
Some larger values still cast correctly.

According to standard, the cast is legal, right? 32-bit float does cover
the range of int64_t, although with some inaccuracy for large values. Or
would this have been fixed in a later msp430-gcc?

As has been pointed out before
https://www.millennium.berkeley.edu/pipermail/tinyos-help/2010-November/048878.html
FTSP TimeSyncP.nc calculateConversion() uses this cast, and it results in
wrong skew values if the points in the timesync table are spaced enough for
int64_t localSum to reach the faulty range.

Setup
msp430tools-gcc-3.2.3-20050607
nescc: 1.3.4

Best Regards
Flemming Nyboe
www.rocketscience.eu
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to