How to double a variable with bitwise shift left in TypeScript

1 Answer

0 votes
let num: number = 7;

num = num << 1;  // This will double the value of num

console.log(num);

 
 
/*
run:
 
14
 
*/

 



answered Mar 9, 2025 by avibootz

Related questions

1 answer 98 views
1 answer 99 views
1 answer 97 views
1 answer 94 views
1 answer 88 views
1 answer 101 views
1 answer 96 views
...