HP Forums

Full Version: Bitwise AND with a variable
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
If i perform an AND between 2 integers it is bitwise:

#160d AND #FFFFh gives result #160d

If one input is a real then the result is 1 if both input nonzero:
160 AND #FFFFh gives result 1

So far so good. However:
x:=#160d
x AND #FFFFh gives result 1 even though x has an integer value.
How can one perform a bitwise AND between integer variables?
Use the BITAND function rather than the AND function: BITAND(x,#FFFFh)

(see the integer function list page 604 of the User Guide)
It is true that the integers in HP Prime can be adjusted to bits, but it manipulates as numeric data, almost equal to real, AND does its common work by returning 1 or 0.
Hello,

Make sure that the object stored in your variable is indeed a binary number.
lower case x is most likely a cas variable. CAS does not support binaries, so they will be a binary to real transform along the way.

If you create a home, non-typed variable (use global, or program variable), then you should be able to store your #160d in it and it will stay an integer.

Cyrille
Reference URL's