Skip to content

Commit

Permalink
add commets to mulOverflow
Browse files Browse the repository at this point in the history
Signed-off-by: fzhedu <fzhedu@gmail.com>
  • Loading branch information
fzhedu committed May 19, 2022
1 parent 8944eaf commit 6448bdc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libs/libcommon/include/common/arithmeticOverflow.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ inline bool mulOverflow(__int128 x, __int128 y, __int128 & res)
return res/x != y; /// whether overflow int128
}

/// Int256 doesn't use the complement representation to express negative values, but uses an extra bit to express the sign flag,
/// the actual range of Int256 is from -(2^256 - 1) to 2^256 - 1, so 2^255 ~ 2^256-1 do not overflow Int256.
template <>
inline bool mulOverflow(Int256 x, Int256 y, Int256 & res)
{
Expand Down

0 comments on commit 6448bdc

Please sign in to comment.