[GRASS-dev] r.mapcalc operator question

Michael Barton Michael.Barton at asu.edu
Wed Aug 25 12:53:57 EDT 2010


Thanks Glynn.

Michael
____________________
C. Michael Barton
Director, Center for Social Dynamics & Complexity 
Professor of Anthropology, School of Human Evolution & Social Change
Arizona State University

voice: 	480-965-6262 (SHESC), 480-727-9746 (CSDC)
fax:          480-965-7671 (SHESC),  480-727-0709 (CSDC)
www: http://www.public.asu.edu/~cmbarton, http://csdc.asu.edu











On Aug 25, 2010, at 3:38 AM, Glynn Clements wrote:

> 
> Michael Barton wrote:
> 
>> In r.mapcalc docs there is an operator >>> for an unsigned right shift.
>> 
>> Is there a corresponding <<< that is not mentioned?
> 
> No. A left shift is neither signed nor unsigned; it always inserts
> zeros into the least significant bits.
> 
> An unsigned right shift inserts zeros into the most significant bits;
> a signed right shift inserts copies of the most signficant bit. This
> ensures that shifting right by N places is equivalent to division by
> 2^N.
> 
> E.g. 0xFFFFFFF0 is either -16 or 4294967280, depending upon whether it
> is signed or unsigned. If it's unsigned, division by 2 should yield
> 0x7FFFFFF8 = 2147483640; if it's signed, it should be 0xFFFFFFF8 = -8.
> 
> Technically, CELL is a signed type, with a range of -2147483647 to
> 2147483647 inclusive (-2147483648 is used for null). But r.mapcalc's
>>>> operator allows you to treat it as an unsigned 32-bit integer with
> a range of 0 to 4294967295 inclusive (excluding 2147483648, which is
> null; maybe that should be changed?).
> 
> -- 
> Glynn Clements <glynn at gclements.plus.com>



More information about the grass-dev mailing list