关于安全数学留空问题.

function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
            // benefit is lost if 'b' is also tested.
            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a == 0) return (true, 0);
            uint256 c = a * b;
            if (c / a != b) return (false, 0);
            return (true, c);
        }
    }

我只想要c而不想要bool该怎么写来着?突然忘记了.

请先 登录 后评论

最佳答案 2021-10-19 15:12

(,uint n) = tryMul

请先 登录 后评论

其它 0 个回答

  • 0 关注
  • 0 收藏,1714 浏览
  • 提出于 2021-10-19 14:37