JavaScript实现切换数字的符号switchSign算法(附完整源码) switchSign.js完整源代码 switchSign.js完整源代码 /** * Switch the sign of the number using "Twos Complement" approach. * @param {number} number * @return {number} */ export default function switchSign(number) { return ~number + 1<