[Question]
  [
**Challenge:**
In the programming language of your choice, accept an [**integer**](https://en.wikipedia.org/wiki/Integer) as input in base 10, and output it in [**the negadecimal notation**](https://en.wikipedia.org/wiki/Negative_base), which is also known as base -10
**Example algorithm:**
[This is an algorithm taken from Wikipedia to convert base 10 to any negative base in VB.NET](https://en.wikipedia.org/wiki/Negative_base):
```
Function toNegativeBase(Number As Integer , base As Integer) As System.Collections.Generic.List(Of Integer)
    Dim digits As New System.Collections.Generic.List(Of Integer)
    while Number <> 0
        Dim remainder As Integer= Number Mod base
        Number = CInt(Number / base)
        if remainder < 0 then
            remainder += system.math.abs(base)
            Number+=1
        end if
        digits.Insert(0, remainder)
    end while
    return digits
end function
```
*Obviously, you can use any algorithm, as long as it fulfills the challenge*
**Example inputs / outputs:**
Input:
```
12
```
Output:
```
192
```
**Another example:**
Input:
```
2048
```
Output:
```
18168
```
**Rule:**
You must not use any built-in methods that solve this problem that exist in your programming language
This is a **code-golf**, so shortest code wins!
  
[Answer]
## JavaScript (ES6), ~~51~~ ~~45~~ 37 bytes
```
f=n=>n&&n%10+((k=n<0)+f(k-n/10|0))*10
```
### Test cases
```
f=n=>n&&n%10+((k=n<0)+f(k-n/10|0))*10
console.log("12 -> " + f(12))
console.log("2048 -> " + f(2048))
```
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 11 bytes
```
_ì ìAn)¥U}a
```
[Test it online!](http://ethproductions.github.io/japt/?v=1.4.3&code=X+wg7EFuKaVVfWE=&input=MTA=)
### Explanation
```
_ì ìAn)¥U}a  // Implicit: U = input integer, A = 10
_        }a  // Return the smallest non-negative integer Z that returns a truthy value
             // when run through this function:
 ì           //   Convert Z to a list of its base 10 digits.
   ìAn)      //   Interpret this as a list of base -10 digits and convert to a base 10 integer.
       ¥U    //   Return (the result == U).
             // Implicit: output result of last expression
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 9 bytes
```
Dḅ-10=ð1#
```
This is a brute-force inverse of negadecimal-to-integer conversion.
[Try it online!](https://tio.run/nexus/jelly#@@/ycEerrqGB7eENhsr///83MjCxAAA "Jelly – TIO Nexus")
### How it works
```
Dḅ-10=ð1#  Main link. Argument: n
      ð    Combine the links to the left into a chain and start a new, dyadic
           chain with left and right argument n.
       1#  Repeatedly execute the chain with left argument k = n, n + 1, ... and
           right argument n until the first match is found.
D          Convert k to decimal.
 ḅ-10      Convert the result from base -10 to integer.
     =     Compare the result with n.
```
[Answer]
## Batch, 82 bytes
```
@set/a"d=%1%%10,n=%1/-10-(a=d>>4),d-=a*10
@if %n% neq 0 %0 %n% %d%%2
@echo %d%%2
```
Batch's division truncates to zero, so if the remainder is negative I need to add 1 (and also add 10 to the remainder) to compensate. The digits are then accumulated in `%2` until the result becomes zero.
[Answer]
# Pyth - 9 bytes
Lel it has the crying emoji in it.
```
fqQijT;_;
```
[Test Suite](http://pyth.herokuapp.com/?code=fqQijT%3B_%3B&test_suite=1&test_suite_input=-10%0A12%0A2048&debug=0).
[Answer]
# Python 3, 35 bytes
```
f=lambda n:n and n%10+f(0-n//10)*10
```
Python port of [Arnauld's](https://codegolf.stackexchange.com/a/105996/61809) algorithm.
Alternatively, for 102 bytes a generic function using the algorithm of the original post:
```
def f(n,b,r=0):
 if n:
  r,n=n%b,n//b
  if r<0:r+=abs(b);n+=1
  return f(n,b,r)+str(r)
 else:return ""
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 10 bytes
```
:⁵NµÐĿ%⁵ṚḌ
```
[Try it online!](https://tio.run/nexus/jelly#@2/1qHGr36Gthycc2a8KZD7cOevhjp7///8bGZhYAAA "Jelly – TIO Nexus")
### Background
Converting a list of non-negative from base **b** to integer can be achieved by left-folding by the function **x, y ↦ bx + y**. To convert and integer *to* base **b**, we must simply reverse that function, i.e., find an expression for **bx + y ↦ x, y**.
In Python (and, by extension, Jelly), the result of the modulo operator is always non-negative, so **(bx + y) % |b| = y**.
Also, integer division always rounds down, making sure that if **q = n / d** and **r = n % d**, the equality **n = qd + r** holds. If **s** is the sign of **b**, then **(sx)|b| + y = bx + y**, so **sx = (bx + y) / |b|** and, therefore, **s((bx + y) / |b|) = x.**
### How it works
```
:⁵NµÐĿ%⁵ṚḌ  Main link. Argument: n
   µ        Combine the links to the left into a monadic chain.
    ÐĿ      Iteratively apply the chain until the results are no longer unique.
            Collect all unique results in an array.
:⁵            Divide the previous return value (initially n) by 10.
  N           Negate; multiply the result by -1.
      %⁵    Take all results modulo 10.
        Ṛ   Reverse the results.
         Ḍ  Convert from base 10 to integer.
```
[Answer]
# [SimpleTemplate](https://github.com/ismael-miguel/SimpleTemplate), 147 bytes
This is a template language I've been working on.  
By no means it is meant to be for golfing.  
It even lacks complete basic math, but it allows to write tiny snippets of PHP directly.  
This works around that issue.
```
{@setN argv.0}{@whileN}{@setM N}{@php$DATA[N]=($DATA[M]/-10)|0;$DATA[R]=$DATA[M]%-10}{@ifR is lower0}{@incby10 R}{@incN}{@/}{@setD R,D}{@/}{@echoD}
```
This throws a bunch of warnings.  
The code is "compiled" into PHP.
Ungolfed, with trash whitespace:
```
{@set no argv.0}
{@while no}
    {@set temp_no no}
    {@php $DATA["no"] = ($DATA["temp_no"] / -10) | 0}
    {@php $DATA["remainder"] = $DATA["temp_no"] % 10}
    
    {@if remainder is lower than 0}
        {@inc by 10 remainder}
        {@inc no}
    {@/}
    {@set digits remainder, digits}
{@/}
{@echo digits}
```
If required, a set-by-step explanation can be added, but I believe that it is pretty straightforward.
---
**Disclaimer**:
The last commit, as of the time of writting this answer, was on 2017-01-07 20:36 UTC+00:00.  
This works on commit [140e56ff38f45fa4fd40fd3ec382094e707b1bad](https://github.com/ismael-miguel/SimpleTemplate/tree/140e56ff38f45fa4fd40fd3ec382094e707b1bad) from 2017-01-06 23:27 UTC+00:00.  
That is the version used to run this answer.
The PHP code is available on <https://raw.githubusercontent.com/ismael-miguel/SimpleTemplate/140e56ff38f45fa4fd40fd3ec382094e707b1bad/SimpleTemplate.php>
I do recommend running this with the last version, but that one works fine for this question.
---
**How to run?**
Create a file with the code and run it like this:
```
<?php
    include 'path/to/SimpleTemplate.php';
    $template = new SimpleTemplate('<code>');
    $template->render(<number>);
```
The value will then be displayed on the screen.
[Answer]
# PHP, ~~71~~ 67 bytes
```
for(;$n=&$argn;$n=$g-$n/10|0)$d=($r=$n%10)+10*($g=$r<0).$d;echo+$d;
```
or 62 bytes for a port of [Arnauld´s answer](https://codegolf.stackexchange.com/a/105996#105996):
```
function n($n){return$n?$n%10+(($k=$n<0)+f($k-$n/10|0))*10:0;}
```
[Answer]
# Mathematica, 49 bytes
```
d@0="";d@n_:=d[-Floor[n/10]]<>ToString[n~Mod~10];
```
Defines a function `d` taking one integer argument, and returning a string. A recursive algorithm—looks like the same algorithm in [Arnauld's answer](https://codegolf.stackexchange.com/a/105996/56178). It does work on negative numbers as well. (It returns the empty string intsead of "0" if the input is 0.) Note for Mathematica golfers: using `±` requires one extra set of parentheses and thus seems not to be any shorter.
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 3 bytes
```
T(в
```
[Try it online!](https://tio.run/##yy9OTMpM/f8/ROPCpv//jQxMLAA "05AB1E – Try It Online") This is not a builtin. It uses builtin base conversion, but not builtin negadecimal conversion.
```
T(в  # full program
  в  # base-10 digits of...
     # implicit input...
  в  # in base...
 (   # negative...
T    # 10
     # implicit output
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 4 bytes
```
₀Nτṅ
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLigoBOz4ThuYUiLCIiLCIyMDQ4Il0=)
Explanation:
```
  τ   # From base 10 to base
₀     # Ten
 N    # Negated
   ṅ  # Join by nothing
      # Implicitly print
```
[Answer]
# C, 68 bytes
```
main(f,a){f&&scanf("%d",&a);f=a?a%10+((f=a<0)+main(0,f-a/10))*10:0;}
```
Instead of printing the resulting number the program just returns it. Obviously this is [Arnauld's answer](https://codegolf.stackexchange.com/a/105996#105996), the only difference is that since C isn't an interpreted language I felt like I should make it a full program as opposed to just a function.
[Answer]
# Rust, 88 bytes
```
fn g(mut n:i32)->i32{let mut r=n%10;n/=-10;if r<0{r+=10;n+=1;}if n==0{r}else{r+g(n)*10}}
```
This is just a recursive version of the algorithm provided in the question.
]