How to use bitwise NOT (~) in JavaScript

1 Answer

0 votes
const a = 7;     // 0000000000000111
const b = -2;    // 1111111111111110

console.log(~a); // 1111111111111000
console.log(~b); // 0000000000000001





/*
run:

-8
1

*/

 



answered Nov 12, 2020 by avibootz

Related questions

1 answer 245 views
1 answer 249 views
249 views asked Jun 14, 2015 by avibootz
1 answer 346 views
1 answer 246 views
1 answer 329 views
1 answer 242 views
...