Javascript Math sign(x)

Description

Javascript Math sign(x)


Math.sign = function(x) {
  if (x > 0) {
    return 1/*from w w w . ja  v  a 2  s.  co m*/
  } else if (x < 0) {
    return -1
  } else {
    return 0
  }
}



PreviousNext

Related