Skip to content

Conversation

@pipermerriam
Copy link

What was wrong?

Un-necessary new library.

How was it fixed?

Figured out how to do it without the library.

Cute Animal Picture

put a cute animal picture link inside the parentheses

result = value
else:
result = bit_vector.shift_left(shift_length).int_val()
result = (value * 2**shift_length) & constants.UINT_256_MAX
Copy link
Author

Choose a reason for hiding this comment

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

A quick test shows that replacing this with (value << shift_length) & constants.UINT_256_MAX passes all the tests.

Copy link
Owner

Choose a reason for hiding this comment

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

Indeed! I have to read up on that magic!

result = value
else:
result = bit_vector.shift_right(shift_length).int_val()
result = (value // 2**shift_length)
Copy link
Author

@pipermerriam pipermerriam Jul 31, 2018

Choose a reason for hiding this comment

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

This one errored out when I changed it to value >> shift_length with an overflow error saying the integer is too large to convert to the c_type, probably something that could be worked around if we're clever.

Copy link
Owner

Choose a reason for hiding this comment

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

It works with the same trick (value >> shift_length) & constants.UINT_256_MAX

Copy link
Author

Choose a reason for hiding this comment

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

viola! huzzah for simple solutions

@cburgdorf cburgdorf force-pushed the christoph/feat/opcodes branch 2 times, most recently from 9614afb to 888f496 Compare August 1, 2018 10:26
cburgdorf pushed a commit that referenced this pull request Sep 27, 2018
[ImgBot] optimizes images
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