Skip to content

Conversation

@pupipipu
Copy link

The bitwise add 2 integers solution will hit infinite loop for negative integers. Added max bit length to avoid exception

" if carry != 0:\n",
" return self.sum_two(result, carry)\n",
" return result;"
" #max bit length, change to 32 for 32bit\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a single space between # and the comments according to PEP8.

" while b != 0:\n",
" if b == max_positive:\n",
" return a ^ min_negative\n",
" a,b = a ^ b,(a&b)<<1\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am reading this just at github.

Here, the 4 space are correct? or there are less?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants