N will be an integer within the representable range of integers in your chosen language.

The Catalogue

The Stack Snippet at the bottom of this post generates the catalogue from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:

\$\begingroup\$This is a trivial challenge with a lot of trivial solutions. There are however some non-trivial solutions too. To voters: Please read the first sentence of this meta post before upvoting builtin functions.\$\endgroup\$
– Stewie GriffinDec 20 '16 at 10:10

8

\$\begingroup\$This could probably use a leaderboard.\$\endgroup\$
– Martin EnderDec 20 '16 at 11:13

2

\$\begingroup\$@MrLister upvote how you want, but really you should look for creativity instead of code length.\$\endgroup\$
– FlipTackDec 28 '16 at 20:13

\$\begingroup\$@MrLister that's the objective winning criterion. but does it really take more effort to type s for a sign builtin, or use some clever bitshifting/maths to work it out? Have a look at this meta post\$\endgroup\$
– FlipTackDec 28 '16 at 20:25

I don't like that 10 bytes of this is eaten up testing for zero, will continue to mull over that. The second half, dd*vr1-d*v-p uses the square root of the square to calculate the absolute value of both our value to test and that value less one. Subtracting the latter from the former yields 1 for a positive value, -1 for a negative.

In functoid there is no support for negative integers since numbers are handled as Church numerals. This solution redefines numbers in a way that supports negative numbers (please refer to the explanation):

Explanation

The definition of negative numbers extends the Church numerals by simply introducing another lambda abstraction that encodes the sign of a number (the first argument, ie. x3). Here is how the numbers -2,-1,0,1,2 would look like in this notation:

Now for the explanation of the above code: The characters < will change the direction to left, this saves us four bytes but makes it more difficult to read.. Here's how the code would look like without doing this:

BbB$K0K21|
@.1,"-"r<
@.([)<

The combinator BbB ensures that K0 and K2 get grouped as one expression each, here's the more verbose code:

$(K0)(K2)1|
@.1,"-"r<
@.([)<

Okay now it's quite readable: First $ will apply the input so we'll have a sign-extended Church numeral as current expression. Applying K0 (constant 0) will evaluate to KK0 (which will "swallow" the next two arguments) in the case of a negative number, in the case of a non-negative number it simply vanishes. In the case of a positive number we'll have K2 which will swallow the argument 1 and else we'll finally get 1.

Summing up the function $(K0)(K2)1 gives the following numbers (regular Church numerals):

if input < 0:
return 0
elif input > 0:
return 2
else:
return 1

The command | will set the direction down iff the current expression evaluates to 0 and up in the other case.

The second line is thus only relevant if the input was negative and it simply prints -1 and terminates

In the other case (ie. hitting the third line) it applies the current expression to [ which decrements it by 1, prints the expression (as a numeral) and terminates

Disclaimer

It might look like the above extension was done just to make this task easier, however this is not the case. In fact most definitions in the untyped (or rather uni-typed) lambda calculus are made because they simplify a lot of operations that one could be interested (such as Booleans or the Church numerals themselves).

As an example the function abs could be "implemented" by just applying the identity function to such an extended numeral which will get rid of one lambda abstraction (and in case of a negative number, keep the absolute value as is).

If you're interested, here is an article that talks more about this definition which is worth a read.

\$\begingroup\$Canvas doesn't interpret 0/0 as 0, it actually errors & removes the 2 items without pushing anything (though I'm about to change that as 0 makes much more sense than nothing). The reason that 0 is outputted is that the stack contains an infinite amount of the inputs. And because of that you can actually remove the ： for 2 bytes\$\endgroup\$
– dzaimaMay 5 '18 at 13:46

How it works

I:0(qm$0)+h
I Input as number
: Duplicate top
0( Change top to "top < 0"
q If top is true...
m$ Push -1 and swap top two; the stack is [-1 x]
Otherwise, skip two commands (m$); the stack is [x]
0) Change top to "top > 0"
+ Add top two
h Print top as number and halt

PowerShell, 22 21 bytes

Boring built-in, calls the .NET function that does exactly what it says on the tin. Ho-hum.Try it online!

-1 byte thanks to Veskah.

For 26 bytes however, we get the classic greater-than less-than equation

param($b)($b-gt0)-($b-lt0)

This, at least, has a little bit of logic and thought put into it. Try it online!

Best yet, though is 44 bytes, where we roll our own solution.

param($b)if("$b".indexof('-')){+!!$b;exit}-1

Here we take input $b, stringify it, take the .IndexOf('-') on it, and use it in an if clause. If the negative sign isn't found, this returns -1, which is truthy in PowerShell, so we turn $b into a Boolean with !, invert the Boolean with another !, cast it as an int with +, leave it on the pipeline, and exit. This turns a positive integer (which is truthy) into $false, then $true, then 1, while turning 0 into $true, then $false, then 0. Otherwise, the .IndexOf returned 0 (meaning it was the first character in the string), which is falsey, so we skip the if and just place a -1 on the pipeline. In either case, output via implicit Write-Output happens at program completion. Try it online!

COW can't compare numbers so N is stored in two cells, (if N is not 0) in turns one will be increased and the other decreased. When eventually one of them reaches 0, the loop will stop.
The sign will be in the next cell.

Detailed Explanation:

[0]: N to be incr [1] = -1 [2]: N to be decr [3] = 1
i=>+>= ; Read N in [0], set [1] = 1 and copy it to [2]
[ ; Loop while [2] is non-zero
>°-<+<< ; Set [3] = -1, increase [2] then point to [0]
[ ; Loop while [0] is non-zero
->>=° ; Decrease [0], point to [2] copy in register and set it to 0 (to exit)
] ;
= ; Paste from register to [2]
] ; When exiting the poited cell could be [0] or [1], in either case...
>o ; ...move one right and it would contain the correct output
moo ] mOo < MOo - OOO ° OOM i
MOO [ moO > MoO + MMM = oom o

I've tried other permutations of memory cells but this seems the best.
Setting [3] (a constant) inside the loop is needed to manage the case N=0.

Your Answer

If this is an answer to a challenge…

…Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.

…Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
Explanations of your answer make it more interesting to read and are very much encouraged.

…Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.

More generally…

…Please make sure to answer the question and provide sufficient detail.

…Avoid asking for help, clarification or responding to other answers (use comments instead).

Code Golf Stack Exchange is a site for recreational programming competitions, not general programming questions. Challenges must have an objective scoring criterion, and it is highly recommended to first post proposed challenges in the Sandbox.