A two's complement implementation in JavaScript