It will not hurt, but I don't see why it is strictly necessary. The first
operand of the % (more a rest than a modulo) operation is already int32_t,
the second operand is a uint_8, the results always has the same sign as the
dividend, as mentioned in the comments.

--Vlado

On Wed, Oct 4, 2017 at 12:31 AM Eric Decker <cire...@gmail.com> wrote:

>
> I think you are right just looking at the math.
>
> However, you will have to test it and watch how the algorithm behaves to
> make sure it is functioning correctly.
>
> I'm not familar enough with the algorithm nor the underlying principles to
> eye ball it and get it right.
>
> If you do figure it out please document it better.
>
> thanks,
>
> eric
>
>
> On Mon, Oct 2, 2017 at 12:55 AM, Jobish John <jobishjohn.m...@gmail.com>
> wrote:
>
>> Dear all,
>>
>> While trying to understand the TinyOS implementation of FTSP, in one of
>> the function, “calculateConversion()” from (TimeSyncP.nc), I have a
>> small doubt in the below part,
>>
>> ----------------------------------------------------------
>> while( ++i < MAX_ENTRIES )
>>    if( table[i].state == ENTRY_FULL )
>>    {          /*
>>                 This only works because C ISO 1999 defines the signe for
>> modulo the same as for the Dividend!
>>              */
>>                localSum += (int32_t)(table[i].localTime -
>> newLocalAverage) / tableEntries;
>>                localAverageRest += (table[i].localTime - newLocalAverage)
>> % tableEntries;
>>                offsetSum += (int32_t)(table[i].timeOffset -
>> newOffsetAverage) / tableEntries;
>>                offsetAverageRest += (table[i].timeOffset -
>> newOffsetAverage) % tableEntries;
>>  }
>> -----------------------------------
>> I think we need to add a typecast (int32_t) for the localAverageRest
>> calculation line also, That is, something like
>> localAverageRest += (int32_t) (table[i].localTime - newLocalAverage) %
>> tableEntries;
>>
>> Kindly suggest..
>>
>> Thanks for your valuable time
>>
>> Regards
>> Jobish John
>> IIT Bombay
>>
>>
>>
>>
>>
>> _______________________________________________
>> Tinyos-help mailing list
>> 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

Reply via email to