[GRASS-user] map algebra logical operators on DCELL rasters not admitted? maybe docs should outline it

Glynn Clements glynn at gclements.plus.com
Wed Oct 21 17:42:11 PDT 2015


G. Allegri wrote:

> > This isn't about the if() function. The bitand() function (to which
> > the error message refers) corresponds to the bitwise-and operator "&".
> >
> > The if() function accepts either integer or floating-point values for
> > its arguments.
> 
> That's what disappointed my client (and me) Glynn: why integer yes and not
> floats? Is it a technical limitation or there's a ratio behind it?
> Anyway did I miss something from the docs? I couldn't find it.

What would you expect the value of (x & y) to be if x and/or y were
floating-point values?

> Why do you that I'm confusing the operators? I've always talked about
> logical operators...

Because you quote an error message which specifically refers to a
*bitwise* operator:

> "Incorrect argument types to function bitand()".

in a message which otherwise only mentions logical operators.

"bitand()" is the name of the bitwise-and function, which corresponds to
the infix "&" operator. I.e. (x & y) is exactly equivalent to bitand(x, y).

This is the same as the "&" operator in C or C++: it evaluates to an
integer where each bit in the result is set (one) if the corresponding
bit is set in both operands, and unset (zero) otherwise. E.g. (23 & 34)
is
	  00010111 (23)
	& 00100010 (34)
	  --------
	= 00000010 ( 2)

Perhaps it would help if you posted the exact expression which is
causing you problems.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list