Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • can you explain more ? is this manipulating bits ? that's seems strange to me. what is 0x7fffffff ? Commented May 3, 2011 at 7:19
  • @silentbang: I'm using each int in the array to hold a 31-bit quantity, so the high-order bit should be 0. If you add two 31-bit numbers (plus carry) you get a 32-bit number, of which the high-order bit is the new carry bit. So you get that bit into carry, and clear it in the result. c[i] &= 0x7fffffff; clears the 32nd bit (the sign bit). I could have said c[i] &= ~(1<<31);. Commented May 3, 2011 at 12:32
  • if using this way, I need to convert decimal to binary number. how do we convert BIGINTEGER as there is nothing enable multiply/divide/plus/substract operations? Commented May 9, 2011 at 15:36
  • @silentbang: OK, pick whatever base you want. If you want to stick to 1 byte per decimal digit, and do the entire thing in base 10, go right ahead. It's the same concept. It will take longer, of course. BTW that's how the IBM 1620 and 360 did decimal arithmetic, and why the Intel x8x processors have the ADC instruction. Commented May 9, 2011 at 16:57