Bitwise AND with a variable - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Bitwise AND with a variable (/thread-9949.html) |
Bitwise AND with a variable - Stevetuc - 01-16-2018 10:07 AM 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? RE: Bitwise AND with a variable - Didier Lachieze - 01-16-2018 10:22 AM Use the BITAND function rather than the AND function: BITAND(x,#FFFFh) (see the integer function list page 604 of the User Guide) RE: Bitwise AND with a variable - Carlos295pz - 01-16-2018 11:31 AM 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. RE: Bitwise AND with a variable - cyrille de brébisson - 01-17-2018 06:16 AM 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 |