Skip to main content
3 of 6
Fixed grammar, avoid additional text in the heading
user avatar
user avatar

PHP, 39 38 bytes

<?=($n=$argv[1])&PHP_INT_MIN?-1:1-!$n;

Not using comparison operators. Should work on most systems.

PHP_INT_MIN has only one bit set: the most significant one. If this is set in the input, the input is negative. !$n casts to integer, evaluates to 0 for positive values and 1 for 0.

Titus
  • 14.8k
  • 1
  • 24
  • 41