L1 A plus B
Write a function that add two numbers A and B. You should not use+
or any arithmetic operators.
Notice
There is no need to read data from standard input stream. Both parameters are given in functionaplusb
, you job is to calculate the sum and return it.
Clarification
Are a and b both32-bit
integers?
Yes.
Can I use bit operation?
Sure you can.
Example
Givena=1
andb=2
return3
Of course you can just return a + b to get accepted. But Can you challenge not do it like that?
Last updated