I have two inputs in binary, and I'm returning the addition result in binary as well.
var addBinary = function(a, b) {
var dec = Number(parseInt(a, 2)) + Number(parseInt(b, 2));
return dec.toString(2);
};
For some insanely big binary like
a = 10100000100100110110010000010101111011011001101110111111111101000000101111001110001111100001101
b = 110101001011101110001111100110001010100001101011101010000011011011001011101111001100000011011110011
I'm outputting
110111101100010011000101110110100000011101000101011000000000000000000000000000000000000000000000000
where the supposed correct output is
110111101100010011000101110110100000011101000101011001000011011000001100011110011010010011000000000
Is it because of overflow? If so, what are the restrictions in Javascript for binary addition overflow? Sorry for the bunch of 1's and 0's.