Skip to content

Commit d1d265b

Browse files
committed
Fix uint256_t/int256_t div/mod operations.
1 parent f8e9f25 commit d1d265b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

include/slimcpplib/long_math_long.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ constexpr type_t half_hi(const long_uint_t<type_t, 2>& value) noexcept;
294294
// make unsigned integer from low and high
295295

296296
template<typename type_t, uint_t size>
297-
constexpr long_uint_t<type_t, size> half_make(const long_uint_t<type_t, size / 2>& high, const long_uint_t<type_t, size / 2>& low) noexcept;
297+
constexpr long_uint_t<type_t, size * 2> half_make(const long_uint_t<type_t, size>& high, const long_uint_t<type_t, size>& low) noexcept;
298298
template<typename type_t>
299299
constexpr long_uint_t<type_t, 2> half_make(const type_t& high, const type_t& low) noexcept;
300300

@@ -402,15 +402,15 @@ constexpr type_t half_hi(const long_uint_t<type_t, 2>& value) noexcept
402402

403403
////////////////////////////////////////////////////////////////////////////////////////////////////
404404
template<typename type_t, uint_t size>
405-
constexpr long_uint_t<type_t, size> half_make(const long_uint_t<type_t, size / 2>& value_hi, const long_uint_t<type_t, size / 2>& value_lo) noexcept
405+
constexpr long_uint_t<type_t, size * 2> half_make(const long_uint_t<type_t, size>& value_hi, const long_uint_t<type_t, size>& value_lo) noexcept
406406
{
407-
constexpr uint_t half_size = size / 2;
408-
long_uint_t<type_t, half_size> result;
407+
constexpr uint_t double_size = size * 2;
408+
long_uint_t<type_t, double_size> result;
409409

410-
for (uint_t n = 0; n < half_size; n++)
410+
for (uint_t n = 0; n < size; n++)
411411
result.digits[n] = value_lo.digits[n];
412-
for (uint_t n = half_size; n < size; n++)
413-
result.digits[n] = value_hi.digits[n - half_size];
412+
for (uint_t n = size; n < double_size; n++)
413+
result.digits[n] = value_hi.digits[n - size];
414414

415415
return result;
416416
}

0 commit comments

Comments
 (0)