HP Forums
Bitwise functions for 27S? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: Bitwise functions for 27S? (/thread-8446.html)

Bitwise functions for 27S? - Dave Britten - 06-02-2017 04:18 PM

Just curious if anybody's tackled these before (only the basics: AND, OR, XOR, and NOT). I could probably come up with something without too much fuss, but no sense reinventing the wheel.

RE: Bitwise functions for 27S? - Dave Britten - 06-05-2017 07:37 PM

Alright, here's my attempt at it, then. Not the fastest thing in the world, but it gets the job done in a pinch. Note that it expects (and returns) decimal values. If you want to use non-decimal numbers, enter/convert them in the BASE menu and store into scratch registers for recalling in the solver.

Enter your operands into A and B, and solve for the operation you want. #NOT works a little differently - it inverts the bits in A, and uses the value in B as the word size, i.e. the result will be padded/trimmed to B bits, as appropriate. This isn't designed to handle any goofy inputs (non-integers or negative values). And if you give it a huge value for B when calculating #NOT, be prepared to wait. Smile

I've added some line feeds and indentation for readability.


I think this would work on the 17BII, 19BII, and palmtops (I developed it on my 200LX). If any of those models doesn't have the IDIV function, just substitute IP(X÷Y) as appropriate.

Comments or improvements welcome.