Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2^256 == 0, 2^255 == -578... #95

Open
davebryson opened this issue Mar 22, 2016 · 1 comment
Open

2^256 == 0, 2^255 == -578... #95

davebryson opened this issue Mar 22, 2016 · 1 comment

Comments

@davebryson
Copy link

In the wiki docs for Serpent, it says that anything over 2^256 will wrap to 1. Using serpent 2.0.2 I'm finding that:

2^256 == 0
2^255 == -5789604461... (note that's negative)

And anything over 2^256 == 0

Is this correct behavior or a bug?

@joeykrug
Copy link

joeykrug commented Jun 24, 2016

That's correct behavior. Serpent uses signed integers by default --- see http://kias.dyndns.org/comath/13.html "if a signed integer has n bits, it can contain a number between -2^(n - 1) and 2^(n - 1) - 1"

uint256 will give you unsigned

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

No branches or pull requests

2 participants