Search code examples
javascriptnode.jsvariablesmathsubtraction

What is the quickest way to subtract a variable from a number and set the variable?


Is there a quicker way to do x = 128 - x?


Solution

  • Short answer: No

    If it was a division or multiplication by powers of 2, you could use bitwise shift operators to make it faster, but in this case, nothing is better than x = 128 - x