Post Reply 
Bitwise AND with a variable
01-16-2018, 10:07 AM (This post was last modified: 01-16-2018 10:08 AM by Stevetuc.)
Post: #1
Bitwise AND with a variable
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?
Find all posts by this user
Quote this message in a reply
01-16-2018, 10:22 AM
Post: #2
RE: Bitwise AND with a variable
Use the BITAND function rather than the AND function: BITAND(x,#FFFFh)

(see the integer function list page 604 of the User Guide)
Find all posts by this user
Quote this message in a reply
01-16-2018, 11:31 AM
Post: #3
RE: Bitwise AND with a variable
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.

Viga C | TD | FB
Visit this user's website Find all posts by this user
Quote this message in a reply
01-17-2018, 06:16 AM
Post: #4
RE: Bitwise AND with a variable
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

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)