6 kyu

BitMath: Addition

Description:

Create a utility function called add for your BitMath class, which will use bitwise operators (&, |, ^, ~, <<**, **>>, and >>>) to add 2 integers a and b without the use of the basic arithmetic operators (+, -, *****, /, and %).

As bitwise operation converts its operands to 32-bit signed integers, parameters in the test cases will be constrained such that:
-230a ≤ 230 - 1,
-230b ≤ 230 - 1

Examples:
BitMath.add(1, 1) --> 2
BitMath.add(2, 2) --> 4
BitMath.add(27, 15) --> 42

Read up on bitwise operators here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators

Note:
Don't comment your code, as // will detected as a false positive instance of the division operator. The increment, decrement, unary negation, and unary plus operators are also disallowed.

If you've enjoyed this kata, also check out:
BitMath: Multiplication

Mathematics
Algorithms
Fundamentals

Stats:

CreatedAug 7, 2016
PublishedAug 19, 2016
Warriors Trained254
Total Skips3
Total Code Submissions583
Total Times Completed124
JavaScript Completions124
Total Stars6
% of votes with a positive feedback rating87% of 55
Total "Very Satisfied" Votes43
Total "Somewhat Satisfied" Votes10
Total "Not Satisfied" Votes2
Total Rank Assessments13
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • hencethus Avatar
  • SpecialEd Avatar
Ad