[Question]
  [
**This question already has answers here**:
 
 
[Visualize long addition with ASCII art](/questions/74127/visualize-long-addition-with-ascii-art)
 (4 answers)
 
Closed 7 years ago.
Everyone knows how to add numbers by hand, right?––Well, I hope so, but for anyone who needs a quick reminder:
To add `17282` and `1342`, you proceed as follows:
1. place the larger (value wise, not number of digits) number above the smaller number and match up the digits
```
17282
 1342
```
2. draw the plus sign (+) to the left of the equation on the second row. The plus sign must be flush with the left side. 
```
 17282
+ 1342
```
3. draw a line of dashes (-) with one dash in each column of the digits of the first line
```
 17282
+ 1342
 -----
```
4. evaluate the expression and write the digits above each column if you need to 'carry' them
```
   1
 17282
+ 1342
 -----
 18624
```
Your output is what you get after applying step #4. You may have trailing whitespace, but there may not be any leading zeroes. 
You must write a program or a function that prints or returns the output. 
The input can be taken as either two separate inputs or an array with two items; the type of the inputs can be either string or integer. 
This is code golf so shortest code in bytes wins!
**Edit:** 
The largest number you could expect to receive as output/the sum is the largest integer that your system will display without exponents (thanks to Adám). 
**More examples:**
```
Input: 
1596, 8404
Output:
1111
 8404
+1596
 ----
10000
Input:
1776, 76
Output:
  11
 1776
+  76
 ----
 1852
Input:
123, 456
Output:
 456
+123
 ---
 579
```
  
[Answer]
# [Dyalog APL](http://goo.gl/9KrKoM), 90 [bytes](http://meta.codegolf.stackexchange.com/a/9429/43319)
```
{⌽↑(⊂⌽s),⍨↓⌽(' + ',⍨' 1'⊃⍨l<⍴s),'-'⍪⍨w⍪⍨' 1'[10|(⍎¨(-l←⍴⍉w)↑s←⍕+/⍵)-(+/0 10⊤⍎)¨⊂[0]w←⍕⍪⍵]}
```
Takes list of two numbers as argument. Needs `⎕IO←0` which is default on many systems.
```
      f←{⌽↑(⊂⌽s),⍨↓⌽(' + ',⍨' 1'⊃⍨l<⍴s),'-'⍪⍨w⍪⍨' 1'[10|(⍎¨(-l←≢⍉w)↑s←⍕+/⍵)-(+/0 10⊤⍎)¨⊂[0]w←⍕⍪⍵]}
      f¨(17282 1342)(1596 8404)(1776 76)(123 456)
┌──────┬─────┬─────┬────┐
│   1  │1111 │  11 │    │
│ 17282│ 1596│ 1776│ 123│
│+ 1342│+8404│+  76│+456│
│ -----│ ----│ ----│ ---│
│ 18624│10000│ 1852│ 579│
└──────┴─────┴─────┴────┘
```
[TryAPL online!](http://tryapl.org/?a=%u2395IO%u21900%20%u22C4%20e%u2190%7B%7B1%3D%u2374%u2375%3A%u236C%u2374%u2375%u22C4%u2375%7D%u2283%7B%u237A/%u2375%7D/%u2395VFI%20%u2375%7D%20%u22C4%20%7B%u233D%u2191%28%u2282%u233Ds%29%2C%u2368%u2193%u233D%28%27%20+%20%27%2C%u2368%27%201%27%u2283%u2368l%3C%u2262s%29%2C%27-%27%u236A%u2368w%u236A%u2368%27%201%27%5B10%7C%28e%A8%28-l%u2190%u2262%u2349w%29%u2191s%u2190%u2355+/%u2375%29-%28+/0%2010%u22A4e%29%A8%u2282%5B0%5Dw%u2190%u2355%u236A%u2375%5D%7D%A8%2817282%201342%29%281596%208404%29%281776%2076%29%28123%20456%29&run) Note that `⎕IO` has been set and `⍎` has been emulated with `e` as `⍎` is banned from TryAPL for security reasons.
### Ungolfed and explained
> 
> `{` An anonymous function
> 
> 
> 
> > 
> > `w ← ⍕ ⍪⍵` *w* gets the textified vertical arrangement of the argument
> >  (the numbers to be added)
> > 
> > 
> > `l ← ≢ ⍉w` *s* gets the count of rows in the transposed *w* (i.e. the
> >  number of columns in *w*)
> > 
> > 
> > `s ← ⍕ +/⍵` *s* gets the textified sum of the argument
> > 
> > 
> > `' 1'[`... index into the string " 1", so zeros give spaces, and ones
> >  give character 1s.
> > 
> > 
> > 
> > > 
> > > `⊂[0] w` enclose down, gets list of pairs of corresponding digits in
> > >  the numbers
> > > 
> > > 
> > > `(+/ 0 10 ⊤ ⍎)¨` for each pair; make into digit(s), then sum
> > > 
> > > 
> > > `(⍎¨ (-l) ↑ s)-` chop left-most digit of grand total to the width of
> > >  the longest input, then make each character into separate number and
> > >  subtract the column sums (if the sum does not add up to the total, the
> > >  discrepancies are due to carrys, so this gives us each column's carry)
> > > 
> > > 
> > > `10|` division remainder when divided by 10
> > > 
> > > 
> > > 
> > 
> > 
> > `]` [end of indexing]
> > 
> > 
> > `w⍪⍨` stack the input numbers below
> > 
> > 
> > `'-'⍪⍨` stack a minus below each column
> > 
> > 
> > `(' + ',⍨' 1'⊃⍨l<⍴s),` prepend a space to the 2nd line, a
> >  plus to the 3nd, a space to the 4rd, and a one
> >  or space to the 1st – depending on if the sum is wider than
> >  the widest input (meaning we need a carry high over the plus )
> > 
> > 
> > `⌽` mirror right-left (so left-justification will be to the right)
> > 
> > 
> > `↓` make table into list of lines (so that differing line lengths are
> >  allowed
> > 
> > 
> > `(⊂⌽s),⍨` append the sum
> > 
> > 
> > `↑` combine list of lines into table (padding the right with spaces as
> >  needed)
> > 
> > 
> > `⌽` mirror back to normal
> > 
> > 
> > 
> 
> 
> `}` [end of function]`
> 
> 
> 
[Answer]
# Python 2.7, ~~201~~ ~~192~~ ~~161~~ ~~155~~ ~~167~~ ~~164~~ 182 bytes:
(*Saved 2 bytes (`192->190`) thanks to TheBikingViking*)
```
def Q(T,Y):O,D=sorted([T,Y]);E=len(`D`);print'%s\n %s\n+%*s\n %s\n %d'%(''.join([' ',i[0]][len(i)>1]for i in[`sum(map(int,u))`for u in zip(`D`,'%0*d'%(E,O))]),D,E,O,'-'*E,sum([T,Y]))
```
A named function that takes input in any order while outputting the correct answer in order of magnitude from top to bottom.
[Try it Online! (Ideone)](http://ideone.com/Eh4ouz)
---
Alternatively, if allowed to take input in order of magnitude (i.e. bigger number first, then smallest), then here is a much smaller solution which also uses a named function at **164 bytes**:
```
def Q(T,Y):E=len(`T`);print'%s\n %d\n+%*d\n %s\n %d'%(''.join([' ',i[0]][len(i)>1]for i in[`sum(map(int,u))`for u in zip(`T`,`Y`.zfill(E))]),T,E,Y,'-'*E,sum([T,Y]))
```
[Try this Version Online! (Ideone)](http://ideone.com/u1JG5E)
[Answer]
# Ruby, ~~192~~ 191 bytes
Returns a multiline string. Input is an array with two strings.
[Try it online!](https://repl.it/ChEZ/1)
```
->o{x,y=o.sort_by!(&:to_i).map{|e|e.reverse.chars}
a,b=o.map &:to_i
k=' '
y.zip(x).map{|z|i,j=z.map &:to_i
k=i+j+k.to_i<10?' ':1}.reverse*''+"
 %s
+%#{s=y.size}s
 %s
%#{s+1}s"%[b,a,?-*s,a+b]}
```
[Answer]
# C (ansi), ~~392~~ 384 Bytes
Saved 8 thanks to Value Ink (392->384)
## Code:
```
char c[9],d[9],p[99]=" %s\n%0s\n+%0s\n %s\n%0i",*t,*b;k,r;main(a,i,m,n)char**i;{m=strlen(i[1]);n=strlen(i[2]);m==n?(strcmp(i[1],i[2])<0?t=i[2],b=i[1]:(t=i[1],b=i[2])):m<n?t=i[2],b=i[1]:(t=i[1],b=i[2]);n>m?:(n^=m,m=n^m,n=n^m);p[18]=p[5]=1+(p[10]=48+n);while(k<n)d[k]=45,a=(n-++k>=0)*(t[n-k]-48)+(m-k>=0)*(b[m-k]-48),r+=a*pow(10,k-1),c[n-k-1]=32+(a+c[n-k]%2>9)*17;printf(p,c,t,b,d,r);}
```
## With Spacing:
```
char c[9],d[9], p[99] = " %s\n%0s\n+%0s\n %s\n%0i", *t,*b;
k,r;
main(a,i,m,n)char**i;{
    m=strlen(i[1]);     //get length of num 1
    n=strlen(i[2]);     //get length of num 2
                        //Set the larger number to the top pointer
    m==n?(strcmp(i[1],i[2])<0?t=i[2],b=i[1]:(t=i[1],b=i[2])):m<n?t=i[2],b=i[1]:(t=i[1],b=i[2]);
    n>m?:(n^=m,m=n^m,n=n^m); //set n to the longer length
    p[18]=p[5]=1+(p[10]=48+n); //set the buffers in the printf string
    while(k<n)     //for every number
        d[k]=45,   //add a dash
        a=(n-++k>=0)*(t[n-k]-48)+(m-k>=0)*(b[m-k]-48), //do the addition
        r+=a*pow(10.,(float)k-1), //add to result
        c[n-k-1]=32+(a+c[n-k]%2>9)*17;  //set 1 if carry or a space otherwise
    printf(p,c,t,b,d,r);    //print to stdio
}
```
## Usage:
### Compile Params:
```
gcc -O3 -ansi -lm -o add add.c
```
### Input:
```
./add 2834 97829
```
### Output:
```
  11 1
  97829
 + 2834
  -----
 100663
```
## Notes:
Only works on numbers up to 8 in length - formatting is hard or I'm really bad at it
I feel like my approach was suboptimal
]