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

Use unsigned integers when dealing with non-negative values #53

Closed
liamsi opened this issue Aug 2, 2016 · 2 comments
Closed

Use unsigned integers when dealing with non-negative values #53

liamsi opened this issue Aug 2, 2016 · 2 comments
Assignees
Labels

Comments

@liamsi
Copy link
Member

liamsi commented Aug 2, 2016

Discussion started here #43 (comment) (refactor node.level to an unsigned integer value or panic/err if methods that expect a non-negative int receive a negative on; find out which approach is safer/faster/more reasonable).

Also, clarify if and how we want to deal with overflows (also in case of uint(32/64) if we go with unsigned values).

@liamsi liamsi added the design label Aug 2, 2016
This was referenced Aug 2, 2016
@liamsi
Copy link
Member Author

liamsi commented Aug 3, 2016

An interesting read on the signed/unsigned question: http://www.soundsoftware.ac.uk/c-pitfall-unsigned

@masomel
Copy link
Member

masomel commented Aug 4, 2016

Good read! I did some small tests, and it seems like uint32and uint64 have the same underflow issue as described in the article. Given this, I think it might be safer to panic/err if methods that expect a non-negative int receive a negative one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants