--- doc/docbase/instrument_scripts/nksp/01_nksp.html 2016/07/10 14:24:13 2935 +++ doc/docbase/instrument_scripts/nksp/01_nksp.html 2016/07/10 14:44:04 2936 @@ -958,7 +958,7 @@

Boolean Operators

To perform logical transformations of boolean data, you may use the - following boolean operators: + following logical operators:

on init @@ -971,10 +971,37 @@ end on

- Remember that with boolean operations, all integer values other than 0 + Keep in mind that with logical operators shown above, + all integer values other than 0 are interpreted as boolean true while an integer value of precisely 0 is interpreted of being boolean false.

+

+ So the logical operators shown above always look at numbers at a whole. + Sometimes however you might rather need to process numbers bit by bit. For + that purpose the following bitwise operators exist. +

+ +on init + message("1 .and. 1 is " & 1 .and. 1) { bitwise "and" } + message("1 .and. 0 is " & 1 .and. 0) { bitwise "and" } + message("1 .or. 1 is " & 1 .or. 1) { bitwise "or" } + message("1 .or. 0 is " & 1 .or. 0) { bitwise "or" } + message(".not. 1 is " & .not. 1) { bitwise "not" } + message(".not. 0 is " & .not. 0) { bitwise "not" } +end on + +

+ Bitwise operators work essentially like logical operators, with the + difference that bitwise operators compare each bit independently. + So a bitwise .and. operator for instance takes the 1st bit + of the left hand's side value, the 1st bit of the right hand's side value, + compares the two bits logically and then stores that result as 1st bit of + the final result value, then it takes the 2nd bit of the left hand's side value + and the 2nd bit of the right hand's side value, compares those two bits logically + and then stores that result as 2nd bit of the final result value, and so on. +

+

Comparison Operators