CodesJava

Easy learning with example program codes

typescript bitwise operators tutorial


TypeScript Bitwise Operators:

JavaScript bitwise operators are used to perform bitwise operations on the operands

TypeScript Bitwise Operators List:

Operator Description Example
& Bitwise AND (10==25 & 20==35) = false
| Bitwise OR (20==30 | 20==40) = false
^ Bitwise XOR (20==30 ^ 30==40) = false
~ Bitwise NOT (~20) = -20
<< Bitwise Left Shift (10<<2) = 40
>> Bitwise Right Shift (10>>2) = 2
>>> Bitwise Right Shift with Zero (10>>>2) = 2

TypeScript Bitwise Operators Example:

var a:number = 2;   
var b:number = 3;
 
var result; 
 
result = (a & b);     
console.log("(a & b) => ",result);
 
result = (a | b);          
console.log("(a | b) => ",result);  
 
result = (a ^ b);  
console.log("(a ^ b) => ",result);
 
result = (~b); 
console.log("(~b) => ",result);
 
result = (a << b); 
console.log("(a << b) => ",result); 
 
result = (a >> b); 
console.log("(a >> b) => ",result);

Try it:

JS Bin on jsbin.com

Please follow and like us:


Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki