Skip to content

Commit

Permalink
Fixed compile error for MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
Rouslan committed Jun 1, 2024
1 parent ab03178 commit 52a3679
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
15 changes: 9 additions & 6 deletions include/poly_ops/large_ints.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1144,11 +1144,13 @@ auto unmul(const T &a,const U &b,modulo_t::type<Mod> = {}) noexcept {
if constexpr(Nr == 1 && detail::int_count<Signed,T> == 2 && Nb == 1) {
# if _POLY_OPS_IMPL_HAVE_DIVX
if constexpr(Signed) {
full_int rem;
r.quot = _POLY_OPS_MSVC_DIV(
compi_hi<2,true>(a),
compi_hi<1,true>(a),
compi_hi<1,true>(b),
&static_cast<full_int&>(r.rem.hi()));
&rem);
r.rem = rem;
} else {
r.quot = _POLY_OPS_MSVC_UDIV(
compi_hi<2>(a),
Expand Down Expand Up @@ -1245,9 +1247,9 @@ namespace detail {
}*/
#endif
template<unsigned int N> void udivmod_shift_sub(
full_uint *_POLY_OPS_RESTRICT a,
full_uint *_POLY_OPS_RESTRICT b,
full_uint *_POLY_OPS_RESTRICT quot) noexcept
full_uint * a,
full_uint * b,
full_uint * quot) noexcept
{
if constexpr(N > 1) {
if(a[N-1] == 0 && b[N-1] == 0) {
Expand All @@ -1271,8 +1273,9 @@ namespace detail {
int end = static_cast<int>(n * sizeof(full_uint) * 8);
for(; shift >= end; --shift) {
quot[n] <<= 1;
if(cmp(a_ref,b_ref) >= 0) {
subborrow<N>(a_ref,b_ref);
compound_uint<N> tmp = a_ref;
if(!subborrow<N>(tmp,b_ref)) {
a_ref.set(tmp);
quot[n] |= 1;
}
_shift_right<false,N>(b_ref,b_ref,1);
Expand Down
4 changes: 2 additions & 2 deletions include/poly_ops/polydraw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ template<typename T> fraction<T,2,1> x_intercept(
std::type_identity_t<T> y) noexcept
{
using namespace large_ints;
return {mul<T,T>(start.x(),y - end.y()) + mul<T,T>(end.x(),start.y() - y),
start.y() - end.y()};
return {mul(start.x(),static_cast<T>(y - end.y())) + mul(end.x(),static_cast<T>(start.y() - y)),
static_cast<T>(start.y() - end.y())};
}

template<typename Coord> struct sweep_cmp {
Expand Down
1 change: 1 addition & 0 deletions tests/stream_output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ poly_ops.hpp is always "coord_t" and Index is always "index_t".
#include <map>
#include <string_view>
#include <ranges>
#include <vector>

#if __has_include (<format>)
#include <format>
Expand Down
3 changes: 2 additions & 1 deletion tests/test_large_ints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include "../include/poly_ops/large_ints.hpp"

using namespace boost::ut;

#ifdef HAVE_GMP_LIBRARY
template<unsigned int N,bool Signed> mpz_class to_gmp(const poly_ops::large_ints::compound_xint<N,Signed> &x) {
Expand Down Expand Up @@ -180,6 +179,8 @@ int main() {
expect(boost::ut::eq((0xfedcba9876543210fedcba9876543210_compi >> 0), 0xfedcba9876543210fedcba9876543210_compi));
expect(boost::ut::eq((0xfedcba9876543210fedcba9876543210_compi << 0), 0xfedcba9876543210fedcba9876543210_compi));
expect(boost::ut::eq((0x0000fedcba9876543210fedcba9876543210_compi << 13), 0x1fdb97530eca86421fdb97530eca86420000_compi));
expect(boost::ut::eq((0x000000000000000000fedcba9876543210fedcba9876543210_compi << 70), 0x3fb72ea61d950c843fb72ea61d950c84000000000000000000_compi));
expect(boost::ut::eq((0x121fa00ad77d742247acc9140513b74458fab20783af1222236d88fe5618cf0_compi >> 1), 0x90fd0056bbeba1123d6648a0289dba22c7d5903c1d7891111b6c47f2b0c678_compi));
};

"Test divide"_test = [] {
Expand Down

0 comments on commit 52a3679

Please sign in to comment.