[Tinyos Core WG] 109 and left shifting
Philip Levis
pal at cs.stanford.edu
Wed Dec 6 16:11:17 PST 2006
One last gasp on the no-shifting vs. left shifting question. One of
my original motivations on why left shifting was useful is that it
allows you to know the general magnitude of the value without having
to know how many significant bits it has. E.g., I see
01 30
In my hex packet dump, or 304 decimal, and I know the value is small.
In contrast, if I am not left shifted, the data does not tell me how
many significant digits there are and so I have no idea if this is,
for example, 60% of the max (9 bits, 0x01ff), 30% of the max (10
bits, 0x3ff), or 7% of the max (12 bits).
Of course, losing the size of the type (uint16_t -> java signed
integer) can hurt you. But otherwise you either need Java to be able
to correlate the data value with a particular sensor driver or send
the significant bits inline.
Phil
More information about the Tinyos-2.0wg
mailing list