Sign function

because javascript math is lame and has no sign function, I pasted one in and put in tests.