Skip to content

Commit

Permalink
updating readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit Kumar authored Jun 22, 2017
1 parent 9b3ee26 commit d0703ad
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
# bitwise-operator
Bitwise Operator
# Bitwise Operator

> The operands of all bitwise operators are converted to signed 32-bit integers in two's complement format.Every number has it's own binary representation, used by those operators. To check dec number's binary value, we use `.toString()` method with base argument - '2' for binary.
**Sometime we even use Bitwise OR as equivalent of Math.floor()**
```
Example -
var temp = 2.987293874;
var result = temp | 0;
```

**Few Uses of bitwise operator**

- We can convert colors from RGA to Hex format.
- Variables swap without using third variable (hint - using xor)(redundant with ES6 swap [a, b] = [b, a]).
- Example section of [https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators].
- Check if number is even or odd `Even Number => [(n & 1) === 0]`
- https://miguelmota.com/blog/bitwise-operators-in-javascript/

0 comments on commit d0703ad

Please sign in to comment.