With a 32 bit float you get 24 bits of value and 8 bits of sign so converting from an integer of larger than 24 bits will entail some resolution truncation.
MS On 9/18/2012 2:45 PM, Eric Decker wrote: > > try using the 4.6.3 compiler. 3.2.3 is really old. > > It isn't clear what level of support for floating point exists. Peter > (the current msp430 gcc maintainer) will have more information. > > But do try 4.6.3 first. You can get it in the msp430-46 package at > http://tinyprod.net/repos/debian/README-46.html > > Thanks for taking the time to look at this. > > On Tue, Sep 18, 2012 at 12:13 PM, Flemming Nyboe > <flemm...@rocketscience.eu <mailto:flemm...@rocketscience.eu>> wrote: > > 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 <http://www.rocketscience.eu> > > > _______________________________________________ > Tinyos-help mailing list > Tinyos-help@millennium.berkeley.edu > <mailto:Tinyos-help@millennium.berkeley.edu> > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help > > > > > -- > Eric B. Decker > Senior (over 50 :-) Researcher > > > > > _______________________________________________ > Tinyos-help mailing list > Tinyos-help@millennium.berkeley.edu > https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help > _______________________________________________ Tinyos-help mailing list Tinyos-help@millennium.berkeley.edu https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help