Joined November 2012
·

Bob Ippolito

San Francisco, CA
·
·
·

The idiomatic way to do this without parseInt is to use |0. This is also the approach adopted by the asm.js spec. The effect is the same as ~~. For example, '1387037027228'|0 === -237409380.

The ~ operator is called bitwise not. ~123 === -124 as this is two's complement arithmetic. The sign does change, but that's not the only thing that changes. The unary - operator performs negation. http://www.ecma-international.org/ecma-262/5.1/#sec-11.4.8

Achievements
139 Karma
0 Total ProTip Views