[Question]
  [
Take an input, and convert it from Two's Complement notation (binary where the first bit is negated, but the rest are taken as normal) into an integer (in a somewhat standard output form). Input can be as a string, a list of digits, a number, or pretty much any other format which is recognizably Two's Complement. Leading zeroes must function properly. Both returning and outputting the value are fine.
Examples:
```
0 -> 0
1 -> -1
111 -> -1
011 -> 3
100 -> -4
1001 -> -7
0001 -> 1
```
Example conversion:
Say our input is 1101. We can see that the first bit is in position 4, so has a positional value of 2^3. Therefore, since it's a 1, we add -8 to our total. Then, the rest of the bits are converted just the same as regular binary (with 101 being the same as 5), so the result is -3.
Example implementation (Mathematica, 40 characters):
`Rest@#~FromDigits~2 - 2^Length@#/2*#[[1]] &`
This implementation takes input as a list of digits.
Code-golf, so shortest solution wins.
  
[Answer]
# JavaScript (ES6), 31 bytes
Expects a binary string.
```
s=>(q=1<<s.length-1,'0b'+s^q)-q
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@7/Y1k6j0NbQxqZYLyc1L70kQ9dQR90gSV27OK5QU7fwf3J@XnF@TqpeTn66RpqGkoGSpqYCEOjrKxhwockZIuR0DTEkDSHSWCUNEJLGGBoNDOAaTbBIgnWCJM0xTEVIGv4HAA "JavaScript (Node.js) – Try It Online")
Uses the classic sign extension formula:
```
sign_extended = (value XOR mask) - mask
```
where only the sign bit is set in `mask` (e.g. `0x80` for a byte).
---
# JavaScript (ES6), 26 bytes
Expects an array of bits.
```
f=a=>1/a?-a:a.pop()+2*f(a)
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/f8/zTbR1s5QP9FeN9EqUa8gv0BDU9tIK00jUfN/cn5ecX5Oql5OfrpGmka0QawCGGhqKujrKxhwoUkbokjrGmLI6wBhLG55AxR5Y0ztBjoGCO0mWOWBBkDlzTGNR5Y3/A8A "JavaScript (Node.js) – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 4 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
N1¦Ḅ
```
A monadic link that accepts a list of `1`s and `0`s and yields an integer.
**[Try it online!](https://tio.run/##y0rNyan8/9/P8NCyhzta/v//H22oY6hjoGMYCwA "Jelly – Try It Online")** Or see the [test-suite](https://tio.run/##y0rNyan8/9/P8NCyhzta/h9uf9S05v//6GiDWJ1oQxDWAUIgbQClDXUMdAxgNFQGwooFAA "Jelly – Try It Online").
### How?
```
N1¦Ḅ - Link: list of 1s and 0s, A
  ¦  - sparse application to A...
 1   - ...indices: 1
N    - ...action: negate
   Ḅ - convert from binary (conversion from base functions allow non-base digits)
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 26 bytes
```
s=>'0b'+s-s[0]*2**s.length
```
[Try it online!](https://tio.run/##y0osSyxOLsosKNHNy09J/Z9m@7/Y1k7dIEldu1i3ONogVstIS6tYLyc1L70k439yfl5xfk6qXk5@ukaahpKBkqamAhDo6ysYcKHJGSLkdA0xJA0h0lglDRCSxhgaDQzgGk2wSIJ1giTNMUxFSBr@BwA "JavaScript (Node.js) – Try It Online")
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 33 bytes
```
lambda n:2*int(n,2)-int(n[0]+n,2)
```
[Try it online!](https://tio.run/##NczBCsIwDAbge58i7NRqO9JNUAbzRdRDZR0Walq6Ivj01W6aS77w/yS@8yNQf4qpzOO1ePO8TwZo6HaOMifZCbXigrd9vcocEnhwBCFa4ijaZM3kHdmFi4HBd5wMMIJvl@hd5g2oMzRiTWKqv5y0L@N5EHLmToiCtYFM16U00/ov3NQzjWtHHaq29MjwR80@ "Python 3.8 (pre-release) – Try It Online")
This is essentially `2 x n - n'` where n is the input and n' is the input with its highest bit repeated. It can be rewritten  `2 x n - 2 x h - n = n - 2 x h` where h is the highest bit of `n`
## [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 34, 33 bytes (@GB)
```
lambda n:eval(f"0b{n[1:]}0-0b"+n)
```
[Try it online!](https://tio.run/##NYxBCsIwFET3OcUnqwSb8kMFJVAvoi5SmmAg/oS0CCKePdpWZzMP3jD5Od8Sdcdcqu8vNdr7MFog4x42Cs9xeNFZm@sbFQ58R7L6VCBCIEjZkUDZFmfHGMhNQhoG34QmQQ@xnXIMs@CgTsDlanIJNIvQrOdJNl4EKSsuC2R6KaWZ1n/CjTqmcd2o/UKbPTD8oWYf "Python 3.8 (pre-release) – Try It Online")
This boils down to `2 x n' - n` where n is the input and n' is the input with the highest bit cleared. This can be rewritten as `2 x n - 2 x h - n = n - 2 x h` where `h` is the highest bit of `n` (in position).
[Answer]
# [Perl 5](https://www.perl.org/) `-pl`, 31 bytes
```
s/.//;$_=-$&*2**y///c+oct"0b$_"
```
[Try it online!](https://tio.run/##K0gtyjH9/79YX09f31ol3lZXRU3LSEurUl9fP1k7P7lEySBJJV7p/39DQ0MuAyA2NDAAYSAHSPzLLyjJzM8r/q/ra6pnYGjwX7cgBwA "Perl 5 – Try It Online")
[Answer]
# [Python 3.8 (pre-release)](https://docs.python.org/3.8/), 38 bytes
```
lambda n:(a:=int(n,2))-(a*2&2**len(n))
```
[Try it online!](https://tio.run/##JYxBCsMgEEXXzSlmVWckAbWbItiLtF1YGqmQTsS4CSFnt8Ru3ocH/6W1fGa@XFOuwT3q5L@vtwe26K2LXJB7QzSgl@ZspJxGRiaqZVzKAg7uQmsteqEatVJ/NnXMswtzhgiRoV1sd0r5yAaxxR2GG2wBI@2C6g8 "Python 3.8 (pre-release) – Try It Online")
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 20 bytes
```
Fold[#+##&,-#,!##2]&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b73y0/JyVaWVtZWU1HV1lHUVnZKFbtf0BRZl5JtLKuXZqDg3KsWl1wcmJeXTVXtaEOENbqcFUbwBiGOgY6BnAGTBLBBEvVctX@BwA "Wolfram Language (Mathematica) – Try It Online")
Input `[digits...]`.
Negates the first bit, and takes the rest as normal.
[Answer]
# x86-16 machine code, 25 bytes
Binary:
```
00000000: 33c0 9903 f1f9 4e13 d2f6 0401 7402 0bc2  3.....N.....t...
00000010: e2f4 7404 33c2 2bc2 c3                   ..t.3.+..
```
Listing:
```
33 C0       XOR  AX, AX             ; AX = 0 (working sum) 
99          CWD                     ; DX = 0 (mask bit)
03 F1       ADD  SI, CX             ; SI = end of input string 
F9          STC                     ; set CF so DX = 1 on first loop
        TC_LOOP: 
4E          DEC  SI                 ; get next significant bit 
13 D2       ADC  DX, DX             ; shift left with CF to least sig bit
F6 04 01    TEST BYTE PTR[SI], 1    ; this bit a '1'?    
74 02       JZ   NEXT_BIT           ; if not, go to next
0B C2       OR   AX, DX             ; flip bit on working sum, CF = 0 
        NEXT_BIT: 
E2 F4       LOOP TC_LOOP            ; loop until end of input string 
74 04       JZ   TC_DONE            ; was most sig bit a 1? 
33 C2       XOR  AX, DX             ; if so, sign extend 
2B C2       SUB  AX, DX 
        TC_DONE: 
C3          RET                     ; return to caller
```
Callable function. Input string at `DS:[SI]`, length in `CX`. Output to `AX`.
[![enter image description here](https://i.stack.imgur.com/yRsWl.png)](https://i.stack.imgur.com/yRsWl.png)
[Answer]
# [C (GCC)](https://gcc.gnu.org), 88 bytes
```
n;main(i,v)char**v;{char*s=*++v;for(;*s;)n=n*2|(*s++-=48);printf("%d\n",n-(**v<<s-*v));}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=fZDBCoJAEIbp2lPIRjC7uuGWkbDac3QIQsy1Bdtk17xUT9JFAh-qnibJk0I7l5nDNz8f_7NND3maNi8Rt9dK0PC9U_ycSAXSq3F6SjQhNb_9DhMT1625uGjgxHCsYkWWdyDGdWkchJiXWqpKAJof9wp5ikL3G0WGkhpj_ujzP5O1gMQsOjLLMw1ZAabSpixkBYgxhjyEcDczh24dyqb_YX8Eryws8_1hcGCHRxobm8aYtjoPSN8mMSqib69p-v0F)
Indented code:
```
n;
main(i,v)char**v;{
    char*s=*++v;
    for(;*s;)
        n=n*2|(*s++-=48);
    printf("%d\n",n-(**v<<s-*v));
}
```
The input is passed through `argv[1]`.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 5 bytes
```
ḣ$NpB
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLhuKMkTnBCIiwiIiwiWzEsMSwxXSJd)
When you steal ideas from Jelly
```
ḣ$NpB # Expects a list of digits
ḣ     # Push the first item and then the rest
 $    # Swap
  N   # Negate the first item
   p  # Prepend the result to the rest of the list
    B # Binary to decimal
```
# [Vyxal](https://github.com/Vyxal/Vyxal), 8 bytes
```
h[†B›N|B
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCJoW+KAoELigLpOfEIiLCIiLCJbMSwxLDFdIl0=)
My original pre-Jelly answer
```
h[†B›N|B # Takes input as a list of binary digits
h[       # If the first bit is 1...
  †      # Vectorized not
   B     # Convert to decimal
    ›    # Add one
     N   # Negate
      |  # Otherwise...
       B # Convert to decimal
```
[Answer]
# [R](https://www.r-project.org), ~~42~~ ~~40~~ ~~39~~ ~~37~~ 36 bytes
*Edit: -2 bytes thanks to [@Giuseppe](https://codegolf.stackexchange.com/users/67312/giuseppe) and -2 bytes thanks to [@Dominic van Essen](https://codegolf.stackexchange.com/users/95126/dominic-van-essen).*
```
\(x)2^rev(a<-seq(x)-1)%*%(x*(-1)^!a)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72waMGiNNulpSVpuhY3VWI0KjSN4opSyzQSbXSLUwuBXF1DTVUtVY0KLQ0gK04xUROi9hajaZpGYrFeZl5JanpqkUZqjkZxSVFxQU5miYaSoaGhko6SkiYQKCvo2inoGnLhVmyAptgYj1pDAwNUg03wK0Zzhjk-Z6CrxutmFJUG-ByBFhCQ0FuwAEIDAA)
Takes input as a list of digits.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 5 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
ć(š2β
```
Input as a list of bits.
Same approach as [*@JonathanAllan*'s Jelly answer](https://codegolf.stackexchange.com/a/245505/52210), but found independently.
[Try it online](https://tio.run/##yy9OTMpM/f//SLvG0YVG5zb9/x9tqGOoY6BjGAsA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeX/I@0aRxcandv0X@d/dLRBrE60IQjrACGQNoDShjoGOgYwGioDYcUCAA).
**Explanation:**
```
ć      # Extract head of the (implicit) input-list; push remainder-list and first
       # item separated to the stack
 (     # Negate this head
  š    # Prepend it back to the list
   2β  # Convert it from a base-2 list to an integer
       # (after which the result is output implicitly)
```
[Answer]
# [R](https://www.r-project.org/), 34 bytes
```
\(x)sum(a<-x*2^rev(seq(x)))/2-a[1]
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72waMGiNNulpSVpuhY3lWI0KjSLS3M1Em10K7SM4opSyzSKUwuBgpqa-ka6idGGsRCVtxhN0zQSi_Uy80pS01OLNFJzNIpLiooLcjJLNJQMDQ2VdJSUgHo0lRV07RR0DblwKzZAU2yMR62hgQGqwSb4FaM5wxyfM9BV43UzikoDfI5ACwhI6C1YAKEB)
Test setup borrowed from [pajonk's R answer](https://codegolf.stackexchange.com/a/245495/95126).
[Answer]
# x86 machine code, 7 bytes
Function that works in 32 or 64-bit mode, with inputs:
* length `n` of the bitstring, in ECX (really just CL)
* ​bit-pattern in the low `n` bits of EAX. (bits in "a number" is an allowed input format)
Output: Signed integer in the full width of EAX.  
In binary 2's complement format, as standard for x86.
Apparently a "number" is a valid output, with no need to convert it ourselves to something having anything to do with decimal, judging by other existing answers, except for a C answer that actually calls `printf` after sign-extending to fill an `int`. (And languages that implicitly print numeric output as a decimal string, but most of the non-golf-language answers are functions that return a number.)
NASM listing: address, machine-code bytes, source
```
                  sign_extend_nbits:
00 F7D9              neg  ecx          ; 32-n = -n after masking to &31
02 D3E0              shl  eax, cl      ; x86 shifts implicitly mask the count &31
04 D3F8              sar  eax, cl
06 C3                ret
```
[Try it online!](https://tio.run/##hVCxTsMwEN37FW9ialHTIlSBGBgYWEBCDGyR4zjpqc658l1K@vXBDkg0EhIezj6/e0/3nhFxXeXPKzbSjaNQy6Ub1HF9twDArgWcHTA799huVowHpGIadRGdkQNxCw242hbwdHAYdreQPTUKYtHYW6XAklVl75OqGZawfupNnPXR6dj6UBmPUtREXXxf00pdOP0Mr6uiWBdlLr@ATcAut9Z4jws/i7/Ic97NP7yalpk8F9okv1MmZfnyljikZRtDf5yMnWWSu0guDyC50V5AgpQLW6OuztHtVlUCDdc4RuL8aQQ952XSuzrj/fn1OhGWkADd06RgGNQdXWycVZzIfSI0CXQ5xVNKkBhPjx/jFw "Assembly (nasm, x64, Linux) – Try It Online")
**Algorithm**: Left shift so the MSB of the narrow input is at the top of the full register (count = 32-n), then arithmetic right-shift back to where it was, leaving the upper bits filled with copies of the MSB. x86 is a 2's complement machine; its arithmetic right shift does 2's complement sign extension.
This problem reduces to 2's complement sign-extension, with no need to read an ASCII string of base 2 digits, as stated by the question's input formats. (But this output format intentionally violates the stated "decimal" output requirement of the question the same way many other answers do. We could `div` in a loop, or maybe `fild` / `fbstp` to make BCD in about twice as many bytes.)
[x86 shifts](https://www.felixcloutier.com/x86/sal:sar:shl:shr) mask their count with `&31` (for 8, 16, and 32-bit operand-size), so the `-n` = `CHAR_BIT*sizeof(int)-n` trick only works for 32 or 64-bit shifts, not 8 or 16. 8086 didn't mask shift counts at all, and [I think when they introduced masking for performance reasons in 186 and 286](https://stackoverflow.com/questions/61745808/why-any-modern-x86-masks-shift-count-to-the-5-low-bits-in-cl/61779201#61779201), they wanted to still allow shifting out all the bits of a 16-bit register. But when 32-bit regs were new, masking was already a thing so they could choose whatever semantics they wanted.
---
This "protest" answer is intended to show how trivial the problem is with the stated allowed input formats, if we follow the precedent of other answers ignoring the "decimal" output requirement.
Computers, and most computer languages, use binary integers. In most of those languages, operators like bitwise `n & 1` being the same as `% 2` (for positive numbers), and `x<<1` being the same as `x*2`, prove that numbers are binary. Converting an integer to an array or ASCII string of decimal digits takes extra work, as in <https://stackoverflow.com/questions/13166064/how-do-i-print-an-integer-in-assembly-level-programming-without-printf-from-the/46301894#46301894> (Or perhaps use x86 `fild` / [`fbstp`](https://www.felixcloutier.com/x86/fbstp) to store the float as packed BCD. Yes this instruction exists, and yes it's microcoded and *very* slow)
If you don't want to require that, don't say "decimal", just say "integer".
But don't maybe don't allow input formats that are already 2's complement integers? A C answer of `f(x){return x;}` is arguably valid if we say that the 2's complement input number must already be in an `int`, which is a fixed-width type and thus requires 2's complement sign-extension for valid integers. I decided to support variable widths by taking a value + length instead of just writing a 1-byte `C3 ret` as a full protest answer, to stick to the spirit of what seemed to be the challenge, 2's complement sign extension without any actual conversion necessary.
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~63~~ ~~57~~ 46 bytes
```
b;f(char*n){for(b=48-*n;*++n;)b+=b+*n-48;n=b;}
```
[Try it online!](https://tio.run/##XU/RaoQwEHy/r1gEIWpCTc/SK2n6UvoV1QeN8U7axsMEKhV/vTbRnNw1sGwyOzObEeQoxDxXrEHiVPaxisam61HFswOJFYuTRLGoSniVxIpkB6Z4xaa5VQa@ylahCMYd2LNowUht9HsBfAwopQGGIF0bTVPfVtT1iS1KZyWHsxRG1k4KI6EY9hhIZusRA/VE0Slt/CJxkuJD9is/yIe3@3x4erX14Oyv3vvLGhsKkNvVqloOVpYyf30G3f7IrkGXX0R3Hog3hEGSLOxoMVszX@W2fmv2hVSwbe42ajttkIluUWnRLfd/2bm3lAYFoQbyAmENoc6VjWYwaLyll5zrwttOu2n@Fc1nedQz@f4D "C (gcc) – Try It Online")
*Saved 11 bytes thanks to [att](https://codegolf.stackexchange.com/users/81203/att)!*
Inputs a string of two's complement \$1\$s and \$0\$s.  
Returns its `int` value.
[Answer]
# [APL(Dyalog Unicode)](https://dyalog.com), 5 bytes [SBCS](https://github.com/abrudz/SBCS)
Takes input as a vector of digits.
```
2⊥-@1
```
[Try it on APLgolf!](https://razetime.github.io/APLgolf/?h=AwA&c=M3rUtVTXwRAA&f=e9Q2UeNRV5POo44ZaY96@w6t0Dy0Ql1BXeNR54JHXW2PuhZpqhsoGCoYGhoqGACxoYEBCAM5QEIdAA&i=AwA&r=tryapl&l=apl-dyalog&m=dfn&n=f)
Port of [att's answer](https://codegolf.stackexchange.com/a/245498/64121). Negate the first (most significant) bit and convert from base 2.
[Answer]
# [MathGolf](https://github.com/maxbergmark/mathgolf/blob/master/math_golf.txt), 8 [bytes](https://github.com/maxbergmark/mathgolf/blob/master/code_page.py)
```
å∞l├∞▌å-
```
Input as a string.
Port of [*@loopyWalt*'s top Python answer](https://codegolf.stackexchange.com/a/245534/52210)
[Try it online.](https://tio.run/##y00syUjPz0n7///w0kcd83IeTZkDpB5N6zm8VPf/fyUDJS4lQxA2BJEGYNLQwABCgoUglKEhkAIA)
**Explanation:**
```
å      # Convert the (implicit) input-string from binary to an integer
 ∞     # Double it
l      # Push the input-string again
 ├     # Pop and push its first character
  ∞    # Double it to two of those characters
   ▌   # Prepend it back
    å  # Convert it from a binary-string to an integer
-      # Subtract the two integers from each other
       # (after which the entire stack is output implicitly as result)
```
[Answer]
# [Haskell](https://www.haskell.org/), 21 bytes
```
(0-).foldl1((-).(2*))
```
[Try it online!](https://tio.run/##y0gszk7Nyflfraus4OPo5x7q6O6q4BwQoKCsW8uVZhvzX8NAV1MvLT8nJcdQQwPI1DDS0tT8n5uYmWebks@lUFCUmVeikqYQbRCLxDFE4egAIbKAAbqAoY6BjgGGALomkMB/AA "Haskell – Try It Online")
A modification of [Aiden Chow's answer](https://codegolf.stackexchange.com/a/245587/78410) to avoid head-tail dissection.
Given that `(+).(2*)` is a shorthand for `\x y -> 2*x+y`, we can replace `+` with `-` to get `\x y -> 2*x-y`. When used with `foldl1`, the modification has the effect of negating every single number of input list `l`, except the first. Then it suffices to negate back the entire result to get the intended answer.
[Answer]
# [Haskell](https://www.haskell.org/), ~~38~~ ~~32~~ ~~29~~ 27 bytes
*Thanks [@Unrelated String](https://codegolf.stackexchange.com/users/85334/unrelated-string) and [@Bubbler](https://codegolf.stackexchange.com/users/78410/bubbler) for helping me golf this in TNB chatroom.*
*Thanks [@Bubbler](https://codegolf.stackexchange.com/users/78410/bubbler) for another -2 bytes by directly setting* `-h` *as the initial value of* `foldl`
```
f(h:t)=foldl((+).(2*))(-h)t
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P00jw6pE0zYtPyclR0NDW1NPw0hLU1NDN0Oz5H9uYmaebUo@l0JBUWZeiUqaQrRBLBLHEIWjA4TIAgboAoY6BjoGGALomkAC/wE "Haskell – Try It Online")
### Explanation
```
f(h:t)=foldl((+).(2*))(-h)t
f(h:t)=                        list input, with the list's head being h and tail being t
                               example: [1,0,0,1]
       foldl(  ....  )(-h)     starting with initial value -h...
             (+).(2*)     t    iteratively apply the function (+).(2*) == \x y->2*x+y
                               across the list t from left to right
                               this converts from a binary list to decimal, with the
                               head of the list negated
                               example: [1,0,0,1] ->  -1 (initial -h) * 2 + 1 = -1
                                        [0,0,1]   -> -1 * 2 + 0 = -2
                                        [0,1]     -> -2 * 2 + 0 = -4
                                        [1]       -> -4 * 2 + 1 = -7 (output)
```
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 29 bytes
I don't think this should work but it does.
```
f(v)=v[1]*=-1;fromdigits(v,2)
```
[Try it online!](https://tio.run/##K0gsytRNL/j/P02jTNO2LNowVstW19A6rSg/NyUzPbOkWKNMx0gTJB1tEKtpa2vABWQZgli6hmCmDhAiuAYwrjFE0kAHrEvXBM6FqjaHqIYLGHIBAA "Pari/GP – Try It Online")
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~51~~ 49 bytes
```
s=>2**s.length/2*-s[0]+parseInt(s.slice(1)||0,2)
```
*-2 bytes because dividing by 2 is golfier than subtracting 1 from length*  
*-1 byte thanks to Matthew Jensen's suggestion to use `slice` over `substr`*
[Try it online!](https://tio.run/##dcxNDoMgEEDhfS8iYMUZto3d9wyNC4LjT0PAOKQr747ptoHtl5f3sV/L7tj21IU4UZ6HzMPTKMXaU1jS2hvV8RvGdrcH0yskwZr95kigPE@4G5ldDBw9aR8XMYsGERspH7c/hjIjQIXLl4ojVvqKl@Mf5gs "JavaScript (Node.js) – Try It Online")
[Answer]
# [Pip](https://github.com/dloscutoff/pip), 8 bytes
```
-:@ggFD2
```
Takes input as a list of bits, given as separate command-line arguments. [Attempt This Online!](https://ato.pxeger.com/run?1=m724ILNgwYKlpSVpuhYrdK0c0tPdXIwgXKjoymhDHQMgNIyFCgAA)
### Explanation
Same approach as [Jonathan Allen's Jelly answer](https://codegolf.stackexchange.com/a/245505/16766):
```
-:@ggFD2
   g      List of cmdline args
  @       First element
-:        Negate in place
    g     Updated list
     FD   Convert from a list of digits
       2  In base 2
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 10 bytes
```
Ｉ↨ＥＡ⎇κι±ι²
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM5sbhEwymxOFXDN7FAwzOvoLREQ1NHISS1KC@xqFIjW0chU0fBLzU9sSRVI1NTEyhlBCSt//@PjjbUUTAAI8PY2P@6ZTkA "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
   Ａ        Input array
  Ｅ         Map over elements
     κ      Current index
    ⎇       If nonzero then
      ι     Current bit else
        ι   Current bit
       ±    Negated
 ↨       ²  Convert from base `2`
Ｉ           Cast to string
            Implicitly print
```
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 46 bytes
```
^1
-
1
01
+`(-|1)0
0$1$1
+`-1|0
^(-?).*
$1$.&
```
[Try it online!](https://tio.run/##K0otycxL/K@q4Z7wP86QS5fLkMvAkEs7QUO3xlDTgMtAxVAFxNU1rDHg4orT0LXX1NPiAgrqqf3/bwBUbGgI0gCkDQxAGMgBEgA "Retina 0.8.2 – Try It Online") Link includes test cases. Explanation:
```
^1
-
```
Change a leading `1` to a `-`.
```
1
01
+`(-|1)0
0$1$1
```
Perform binary to unary conversion, counting `-` as a digit, which causes it to be raised to the appropriate power of 2.
```
+`-1|0
```
Subtract the value of the lower order bits from that power of 2.
```
^(-?).*
$1$.&
```
Convert to decimal, keeping the leading sign if the number is negative.
[Answer]
# [Ruby](https://www.ruby-lang.org/), 28 bytes
```
->n{eval"0b#{n}0-0b"+n[0]+n}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y6vOrUsMUfJIEm5Oq/WQNcgSUk7L9ogVjuv9n9BaUmxQrS6oaGhuo66AZg0NDCAkGAhEBWrl5tYoKGWpvkfAA "Ruby – Try It Online")
[Answer]
# APL+WIN, 27 bytes
Prompts for two's compliment as vector of integers
```
(1+¯2×n)×n+2⊥1↓2|(n←↑b)+b←⎕
```
[Try it online! Thanks to Dyalog APL Classic](https://tio.run/##SyzI0U2pTMzJT9dNzkksLs5M/v@ob6qvz6O2CcZcQJanP5BlyPWooz3tv4ah9qH1Roen52kCsbbRo66lho/aJhvVaOQB1Txqm5ikqZ0EYvVN/Q9Uz/U/jctQAQi50rgMoLShgoGCAYyGyoBZAA "APL (Dyalog Classic) – Try It Online")
[Answer]
# [Desmos](https://desmos.com/calculator), 52 bytes
```
L=l.length-2
f(l)=total(2^{[L...0]}l[2...])-2^Ll[1]2
```
\$f(l)\$ takes in a list of bits and outputs the corresponding decimal form.
[Try It On Desmos!](https://www.desmos.com/calculator/tkfvixmsgg)
[Try It On Desmos! - Prettified](https://www.desmos.com/calculator/zqcdshn9dh)
[Answer]
# TI-Basic, ~~35~~ 29 bytes
```
sum(Ansseq(2^(dim(Ans)-I)(1-2(I=1)),I,1,dim(Ans
```
Takes input as a list of digits in `Ans`. Output is as an integer in `Ans` and is displayed.
[Answer]
# Javascript (ES2020), 33 chars
```
s=>BigInt.asIntN(s.length,"0b"+s)
```
Test:
```
f=s=>BigInt.asIntN(s.length,"0b"+s)
console.log(`0 -> 0
1 -> -1
111 -> -1
011 -> 3
100 -> -4
1001 -> -7
0001 -> 1`.split`
`.map(x=>x.match(/^(\S+) -> (\S+)$/))
.every(([,s,key])=>f(s)==key))
```
[Answer]
# [Piet](https://github.com/cincodenada/bertnase_npiet) + [ascii-piet](https://github.com/dloscutoff/ascii-piet), 46 bytes
```
tlrdveccsittttttbbbuebV???? vuikuemmaiitdem vV
```
Input the binary as a string space separated bits, with `2` being the [sentinel value](https://codegolf.meta.stackexchange.com/a/24639/96039) (`2` is a valid sentinel value because the input only contains `0`'s and `1`'s). For example, `1001` is inputted as `1 0 0 1 2`.
[Try It Online!](https://tio.run/##rVltb9s4Ev6uX8FTgK3cOIqd7hZ3QdxF2rptcGkSJN0WuFwgUBZtM7EoLUU5yd3u/fXeDCnJpOTa6fVcoJWo4fCZ9xk2psX864QqcnREno3P3z0jrwgtJpzv5ZypMH/0dv6yXxZyP@ZiP39U80y88Dye5plUpHgs@oRnfULlLKeyYN5UZim5ODklFcVJSmfM8z78No4@Hl/9nYzIIB4Oh97r0@M35m0wGMDbb@PqZei9vxyPz8zbcOBdjt@aTUD25cPJp3HDwjs9ef/h09n46spmjezeHl82vOH17Pzy4/FpzREW9MaaK7wDRTQ@P7XYmI1ewqaEiUmWsEiw@wUXrAi0ciJUTu/QI/AzC/ojbF59Dot8wZXZ1NOUhlXS0F7f6OVpJgkuES5sZoY7/vhUf18t4G@HfCqlIGrOCHJdELAhvjCRkAxg08m85qoywlVBQMQWB/Z7yZd0wYRyPixooaLJnEpkDDgzmQTI6npveNPbQPnTiPzHUmXrsJOpxpfS4o6oLLsz0Ou9WakQdi4BLo0XjEgqZqzf4lHM@VSBMCSmkzsjWWuHswEV5yA8Ii8OXDV2pdgdkZc/OzS13ZAE1DGZy8DZ0ltLrY0Y0jwHixj1HYL@yK7DzmyVTKEtfT@8zbgIHA4944YJ2@KG@BjdczVvaACq7zcepsE3HobUjoMZ2WDHP4XfcbQ5kwx0n5WLRDwD5TNCxSNpzuGi8jwNmyyZLHgmWkxiBigYEPKCTEsxUUBCaJIUuDd1iCeZUFyUK1u2fHGlOAu88UBi@V9bjOMqUNQcQgVQiExh0FQBo2NlxiBOcloUIIaay6yczVtMAPkc/Sxx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R3Ca/N1FNiy4brrcRNsTajp3qpvqg2KZLDgyLsqPusPr6IOvodxOZ0y2Rw/Pn/nTeZplpDdh9b/e3rO/4r@QcJ95ztMcfi0h/UnzMXsq1rIZMkmE2gk9S@O45LFn3@FH1mW/K5kKfS0HEyVkuXnr3iytw9q2Uc2@0IniL3fW0yHZAB/huTgvw)
Image format (46 codels)
[![](https://i.stack.imgur.com/iqwXk.png)](https://i.stack.imgur.com/iqwXk.png)
Enlarged for clarity (codel size = 50)
[![](https://i.stack.imgur.com/Zs2M3.png)](https://i.stack.imgur.com/Zs2M3.png)
]