How to double value without using any arithmetic operation | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to double value without using any arithmetic operation

13th Feb 2019, 6:54 AM
Ganesh Chevale
Ganesh Chevale - avatar
2 Answers
+ 7
For integers: left shift by one. Not sure about Java, but in other languages it would look like this: n << 1
13th Feb 2019, 7:08 AM
Anna
Anna - avatar
+ 5
The same for Java; (2 << 1) == 4
13th Feb 2019, 8:07 AM
Lev Tolstoy SPB
Lev Tolstoy SPB - avatar