Skip to content

Commit bee39f2

Browse files
committed
Speedup multiplication
1 parent 5f7e612 commit bee39f2

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

include/int256_t.hpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,13 @@ class int256_t
154154
int256_t operator*(const int256_t& other) const
155155
{
156156
auto max64 = prt::numeric_limits<std::uint64_t>::max();
157-
auto max128 = prt::numeric_limits<uint128_t>::max();
158157

159158
if (low <= max64 &&
160159
other.low <= max64 &&
161-
(high == 0 || (uint128_t) high == max128) &&
162-
(other.high == 0 || (uint128_t) other.high == max128))
160+
high == other.high &&
161+
(high == 0 || high == -1))
163162
{
164-
int256_t res(low * other.low, 0);
165-
166-
if (high != other.high)
167-
res.high = max128;
168-
169-
return res;
163+
return int256_t(low * other.low, high);
170164
}
171165
else
172166
{

0 commit comments

Comments
 (0)