Nodejs Number Sign sign(x)

Here you can find the source of sign(x)

Method Source Code

Math.sign = function(x) {
  x = +x;/*from  w  w  w  .j a  va 2 s .c  om*/
  if (x === 0 || isNaN(x))
    return x;
  return x > 0 ? 1 : -1;
}

Related

  1. sign()
    Math.sign = function(x) {
      if (x > 0) {
        return 1
      } else if (x < 0) {
        return -1
      } else {
        return 0
    
  2. sign(d)
    Math.prototype.sign = function(d) {
      return d<0 ? -1 : 1;
    };
    
  3. sign(x)
    Math.sign = Math.sign || function (x) {
        return x === 0 ? 0 : x / Math.abs(x);
    };
    
  4. sign(x)
    Math.sign = function(x) {
      if (x > 0) {
        return 1
      } else if (x < 0) {
        return -1
      } else {
        return 0
    
  5. sign()
    Number.prototype.sign = function() {
      if(this > 0) {
        return 1;
      } else if (this < 0) {
        return -1;
      } else {
        return 0;
    
  6. sign()
    Number.prototype.sign = function() {
        return (this>0) - (this<0);
    };