Boolean arithmetic

By | 2002-06-01

This program includes functions for performing Boolean (bitwise) AND, OR, and XOR; as well as left shift, right shift, and one’s complement. Right now, the subroutines are set up to use the values in the textboxes and output the results to another text box. However, you can easily modify them to take passed variables and return the results as a function.

Original Author: Derek Haas

Inputs

AND, OR, XOR, Shift Left, and Shift Right take the two numbers to be operated on, One’s Complement takes a single number.

Assumptions

A very brief explanation of boolean arithmetic:
AND – Compares each bit of one number to the corresponding bit in another number. If both are 1, then the corresponding bit in the output is 1
OR – Same as above, except the outputted bit is 1 if either or both input bits is 1
XOR – Same as above, except the outputted bit is 1 only if either of the input bits is 1 (not both)
Shift Left – All bits are moved left the given number of spaces and 0’s are filled in from the right. Bits that move out of the variable are lost.
Shift Right – Same as above, except bits are moved right, with 0’s filled in from left. Bits shifted out are lost.
One’s Complement – All 1’s become 0’s and all 0’s become 1’s

Returns

Puts the result into a text box

Attachments

FileUploadedSize
CODE_UPLOAD273.zip9/3/2020 3:45:00 PM4531
Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.