how subtraction two number, without use minus operator (-)? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 2

how subtraction two number, without use minus operator (-)?

use of other operators

20th Feb 2017, 10:28 PM
Mohammad Sahrayi
Mohammad Sahrayi - avatar
1 Réponse
+ 2
You could use bitwise operators JS: var a =6; var b = 2; var subtract; var subtract = a + (~b +1); console.log(subtract); //4
20th Feb 2017, 10:51 PM
tida
tida - avatar