Do not use Math.sign().

Fixes #1333 (see comment from @eush77).

Apparently, `Math.sign()` is not standard, and is not in all versions of chrome/chromium.