On Thu, Oct 11, 2012 at 5:04 AM, <[email protected]> wrote:

> Dear all.
>
> Please someone know what is the difference between 1024L and 1024U in
> TinyOS.
>

basic C.   So first I would encourage you to pick up a copy of Harbison and
Steele C Reference.   Excellent reference.

1024U is an unsigned int.   Now int isn't specified as to size.  So it is
compiler dependent.   For the gnu msp430 toolchain an int is 16 bits so
1024 is an unsigned 16 bit integer.   0-65535.   0-0xffff.   1024L = 0x0400

1024L is a signed long so is 32 bits and signed.  1024L = 0x00000400


> I was reading this piece of code in TinyOS and I've entered in doubt.
>
>
>   DIS_INTERVAL = 3*1024U,
>   DEFAULT_LIFETIME = 1024L * 60 * 20, // 20 mins
>

Weird code.   So I'm not surprised it is confusing.  Frankly doesn't make a
whole lot of sense why they used 3*1024U in one place and 1024L in the
other.  1024U would be appropriate in both places.   In the second if one
wanted to make sure that a 32 bit result was used I would use 1024UL.

In practice it probably doesn't hurt anything.   But does look weird.

eric
old guy (being doing this for a while)


>
> Thanks in advance.
>
> Alejandro
>
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>



-- 
Eric B. Decker
Senior (over 50 :-) Researcher
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to