2018-06-27 18:05:18 +03:00

9 lines
190 B
JavaScript

/**
* Switch the sign of the number using "Twos Complement" approach.
* @param {number} number
* @return {number}
*/
export default function switchSign(number) {
return ~number + 1;
}