Implementing Binary Arithmetic Given two binary numbers (strings containing 0s and 1s), perform operations on them, with one problem: You must keep them in binary. That means no going binary(integer(n1)+integer(n2)) or anything like that.

Input: Two binary numbers, n1 and n2, and a number between 0 and 3, o, defining the operator. The two binary numbers will be the same length.

Output: 
If o is 0, return n1+n2 as a binary number.
If o is 1, return n1-n2 as a binary number.
If o is 2, return n1*n2 as a binary number.
If o is 3, return n1/n2 as a binary number, using floor division.
The output will not be the same length as the input. Please truncate all leading zeros.

If you implement Two's Complement, subtract 10% off your character count, up to a limit of 50. Truncate to length(n1)+length(n2) digits.

Test Cases:
n1=01010, n2=10101, o=0: 11111
n1=11110, n2=01010, o=1: 10100
n1=0010, n2=1000, o=2: 10000
n1=1011010, n2=0010001, o=3: 101

Shortest code wins. Good luck!
Python, 429 chars - 10% bonus = 386.1

Numbers are kept in little endian order, which is stretching the rules a bit but makes for easier processing.  Maximum number size is 32 bits.  Addition is standard, subtraction is implemented by x-y = x+~y+1 (throwing away the carry out of the 32 bits), multiplication is done using the Russian Peasant algorithm, and division is done with repeated subtraction.

z,i='01'
P=z*32
def A(x,y):
 r='';c=z
 for a,b in zip(x+P,y+P):k=(a+b+c).count(i);r+='0101'[k];c='0011'[k]
 return r[:32]
S=lambda x,y:A(A(x,''.join(chr(ord(c)^1)for c in y+P)),i)
def M(x,y):
 r=''
 while y:
  if y[0]==i:r=A(r,x)
  x=z+x;y=y[1:]
 return r
def D(x,y):
 x=(x+P)[:32];y=(y+P)[:32];r=''
 while x[::-1]&gt;=y[::-1]:r=A(r,i);x=S(x,y)
 return r
def B(x,y,o):r=[A,S,M,D][o](x,y).rstrip(z)[:len(x)+len(y)];return[r,z][r=='']


B is the function of interest, here is its result on the test cases:

print B('01010','10101',0)
11111
print B('01111','01010',1)
00101
print B('0100','0001',2)
00001
print B('0101101','1000100',3)
101