You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, yeah, it looks like I made a mistake in two places at once.
It really should have been an unsigned shift. I tried to test the correctness of this function using Ratio but there was an incident with float64 rounding.
Description
The checkedAdd will return (maxInt64 - 2) instead of maxInt64 as the comment saying.
(A possible fix could be:
((naiveSum >> 63) ^ 1)
=>int64((uint64(naiveSum)>>63)^1)
)To Reproduce
Steps to reproduce the behavior:
run this test:
Expected behavior
return maxInt64 when overflow.
The text was updated successfully, but these errors were encountered: