-
Notifications
You must be signed in to change notification settings - Fork 12
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
run test workflow at PR opening #101
Conversation
const c = a * b; | ||
assert(c / a == b, "SafeMath: multiplication overflow"); | ||
const c = a * b; | ||
assert(c / a == b, 'SafeMath: multiplication overflow'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not doing the assert before the calculation as the others ?
assert(c / a == b, 'SafeMath: multiplication overflow'); | |
assert( b <= u64.MAX_VALUE / a, 'SafeMath: multiplication overflow'); |
* @returns Returns the integer division of two unsigned integers. Reverts on | ||
* division by zero. The result is rounded towards zero. | ||
*/ | ||
static div(a: u64, b: u64): u64 { | ||
assert(b > 0, "SafeMath: division by zero"); | ||
const c = a / b; | ||
assert(b > 0, 'SafeMath: division by zero'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert(b > 0, 'SafeMath: division by zero'); | |
assert(b != 0, 'SafeMath: division by zero'); |
const c: u64 = a + b; | ||
assert(c >= a, "SafeMath: addition overflow"); | ||
const c: u64 = a + b; | ||
assert(c >= a, 'SafeMath: addition overflow'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be done before the calculation
assert(c >= a, 'SafeMath: addition overflow'); | |
assert(b <= u64.MAX_VALUE - a, 'SafeMath: addition overflow'); |
Thanks @gregLibert for your code review, I have created a issue that reference it #102 |
No description provided.