Skip to content
Akin C edited this page Apr 15, 2018 · 16 revisions

Welcome to the Javascript-bitwise-operations-with-string-inputs- wiki!

This repository is part of a larger project!

◀️ PREVIOUS PROJECT| NEXT PROJECT ▶️


A convenient feature of javascript is the possibility to use some specific bitwise operators with string operand(s). The operand(s) will be automatically converted when using the following operators:

Operator Name
"~" NOT
"^" XOR
"&" AND
"|" OR
"<<" Left Shift
">>" Right Shift
">>>" Zero Fill Right Shift
"*" Multiplication

On closer examination it is obvious that the last operator in the table is not a bitwise one. Nevertheless the "*" has the same abilities to handle operands as the rest.

For a better understanding here are some js examples:

"2" * "2" //result should be 4
"14" | "9" //result should be 15

Also mixing string with integer values should lead to a correct result:

"2" * 2 //result should be 4

Content

The user interaction part should look like the content as seen below by starting "index.html" in a web browser.

ERROR: No image found!

There is also a helpfull describing note which can be found when starting "index.html".

The results could be displayed as shown in the picture below.

ERROR: No image found!

The colored areas are just for a better readability in the wiki and are not part of the content. To use the project just download the files and execute "index.html". Note that all files should be placed in the same folder so that the functionality of the code is guaranteed.

Clone this wiki locally