![]() Performing a bitwise operation between 53 and 92 means performing a logic operation between their binary representation. Let’s consider a second decimal number, 92, converted in binary will give 01011100. We can easily do the conversion with the Scilab function dec2bin(). For example, decimal 53 is 00110101 in binary. Bitwise operations means performing logic operation on bits ( 0 and 1) rather than logic states true or false.Ī decimal number can be converted to a binary number. In computer engineering, IT, embedded systems, control engineering, software engineering, bitwise operations are a common practice. T T T T F F F T Bitwise operations – predefined Scilab functions The Scilab XNOR operation between A and B is:Īll the above operations can be summarized in a Scilab script file, as: clcĭisp()Įxecuting the script file (Scilab instructions) will output in the Scilab console: In Boolean algebra, the logic operation AND between two variables A and B, is represented as: \ We are going to apply the NOT gate only to the variable A, as: To exercise the complete truth tables for the basic logic operations (gates), we are going to define the Boolean variables A and B as vectors of logic states: To use the elementary logical operators, let’s define two Boolean variables A and B.Īpplying the logical NOT to the A variable gives:Īs expected, the negation of a true variable ( %T) will output a false value ( %F).Īpplying the logical AND to the Boolean variables A and B, gives:Īpplying the logical OR to the Boolean variables A and B, gives: Gives the element-wise logical OR of two Boolean variables Gives the element-wise logical AND of two Boolean variables Gives the element-wise negation of a Boolean variable Scilab has three elementary functions defined for logical operations. ![]() To get a basic understanding on the logic operations (logic gates) read the article Logical operations and boolean functions. In this article we are going to use Scilab to perform logic operations with Boolean variables and bitwise operation with integer variables.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |