<commit_before><commit_msg>leetcode-371 sum of two integers<commit_after>package misc.bitmanipulation.lc371_sumoftwointegers;

/**
 * Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.
 * Example: Given a = 1 and b = 2, return 3.
 */
public class Solution {

    public int getSum(int a, int b) {
        while (b != 0) {
            int c = a & b;
            a = a ^ b;
            b = c << 1;
        }
        return a;
    }

    public int getSum2(int a, int b) {
        int result = 0;
        int carry = 0;
        while (a > 0 || b > 0) {
            carry = (a & ~1) & (b & ~1);
            //result = (result << 1) &
        }
        return result;
    }

}
{'fraction_non_alphanumeric': 0.12150837988826815, 'fraction_numerical': 0.02653631284916201, 'mean_word_length': 1.5698924731182795, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5715369', 'n_tokens_mistral': 255, 'n_tokens_neox': 234, 'n_words': 85}