Implement BCD Arithmetic Write the shortest function you can that takes two binary-coded decimal integers and a character indicating an arithmetic operation to perform and return the result.

Input Specification
You will be passed two 32-bit bit patterns representing unsigned BCD integers.  In C or Java, for example, you would be passed an int (unsigned, if you prefer).  The third argument to your function will be a single character denoting what operation to perform.  If your language requires fixed return sizes, return a 32-bit result and ignore overflow.  Your return value should also be encoded as a BCD.

You should support +, -, *, /, and %.  For subtraction, the first argument is the minuend and the second argument is the subtrahend.  For division and modulo, the first argument is the quotient and the second is the divisor.

Example

bcd(0x00000127, 0x00000003, '+') =&gt; 0x00000130 // NOT 0x0000012A
Python - 47 chars

bcd=lambda*a:&quot;0x%08d&quot;%eval(&quot;%x%s%x&quot;%(a*2)[::2])

tests
&gt;&gt;&gt; print bcd(0x00000127, 0x00000003, '+')
0x00000130
&gt;&gt;&gt; print bcd(0x00000127, 0x00000003, '*')
0x00000381
&gt;&gt;&gt; print bcd(0x00000127, 0x00000003, '/')
0x00000042
&gt;&gt;&gt; print bcd(0x00000127, 0x00000003, '-')
0x00000124