Skip to content

Conversation

@PatrickPijnappel
Copy link
Contributor

The original code would crash on negative values.

  • Added a test for this case.
  • Patch passes build-script -R -t.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this might be simpler, and yet produce the same result: let bitRaw = (intResult + 2) % 2.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, that would rely on the precondition that intResult >= -2. This is true for all current calls to the function, but the way it's written now trivially eliminates this precondition.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK.

@gribozavr
Copy link
Contributor

Thank you! Please wrap to 80 columns.

@PatrickPijnappel
Copy link
Contributor Author

@gribozavr Wrapped to 80 columns.

gribozavr added a commit that referenced this pull request Dec 21, 2015
[stdlib] Fix bug in Bit with-overflow arithmetic
@gribozavr gribozavr merged commit c486a3a into swiftlang:master Dec 21, 2015
@PatrickPijnappel PatrickPijnappel deleted the bit-fix branch December 21, 2015 03:10
freak4pc pushed a commit to freak4pc/swift that referenced this pull request Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants