Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Copyright 2021 Alexander Grund
# Copyright 2022 James E. King III
# Copyright 2023 Matt Borland
# Copyright 2026 Christopher Kormanyos
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -93,7 +94,7 @@ jobs:
fi
git config --global pack.threads 0

- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
# For coverage builds fetch the whole history, else only 1 commit using a 'fake ternary'
fetch-depth: ${{ matrix.coverage && '0' || '1' }}
Expand All @@ -107,7 +108,7 @@ jobs:
restore-keys: ${{matrix.os}}-${{matrix.container}}-${{matrix.compiler}}-

- name: Fetch Boost.CI
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
repository: boostorg/boost-ci
ref: master
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/multiprecision.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2020 Evan Miller
# Copyright 2020 Matt Borland
# Copyright 2021 John Maddock
# Copyright 2021 Christopher Kormanyos
# Copyright 2021, 2026 Christopher Kormanyos
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)

Expand Down Expand Up @@ -31,7 +31,7 @@ jobs:
compiler: [ g++-14 ]
suite: [ specfun_mpfr, specfun_gmp, specfun_cpp_dec_float, specfun_cpp_bin_float, specfun_float128, specfun_cpp_double_double ]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: '0'
- name: Set TOOLSET
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
standard: [ c++14, c++17 ]
suite: [ github_ci_block_1, github_ci_block_2 ]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: '0'
- name: Set TOOLSET
Expand Down Expand Up @@ -155,7 +155,7 @@ jobs:
standard: [ c++17, c++20 ]
suite: [ specfun_mpfr, specfun_gmp, specfun_cpp_dec_float, specfun_float128, specfun_cpp_double_double ]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: '0'
- name: Set TOOLSET
Expand Down Expand Up @@ -217,7 +217,7 @@ jobs:
standard: [ c++14, c++17, c++20, c++23 ]
suite: [ standalone ]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: '0'
- name: Set TOOLSET
Expand Down Expand Up @@ -279,7 +279,7 @@ jobs:
standard: [ c++20 ]
suite: [ arithmetic_tests, functions_and_limits, conversions, cpp_int_tests, misc ]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: '0'
- name: Set TOOLSET
Expand Down Expand Up @@ -341,7 +341,7 @@ jobs:
standard: [ c++20 ]
suite: [ arithmetic_tests, functions_and_limits, misc ]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: '0'
- name: Set TOOLSET
Expand Down Expand Up @@ -405,7 +405,7 @@ jobs:
standard: [ 14, 17 ]
suite: [ github_ci_block_1, github_ci_block_2 ]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: '0'
- name: Checkout main boost
Expand Down Expand Up @@ -448,7 +448,7 @@ jobs:
standard: [ 14, 17, 20 ]
suite: [ github_ci_block_1, github_ci_block_2 ]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: '0'
- name: Checkout main boost
Expand Down Expand Up @@ -486,7 +486,7 @@ jobs:
standard: [ 14, 17, 2a ]
suite: [ github_ci_block_1, github_ci_block_2 ]
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
fetch-depth: '0'
- name: Checkout main boost
Expand Down
6 changes: 3 additions & 3 deletions include/boost/multiprecision/cpp_int.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
////////////////////////////////////////////////////////////////
// Copyright 2012 - 2022 John Maddock.
// Copyright 2022 Christopher Kormanyos.
// Copyright 2022, 2026 Christopher Kormanyos.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at https://www.boost.org/LICENSE_1_0.txt)
Expand Down Expand Up @@ -393,14 +393,14 @@ struct cpp_int_base<MinBits, MaxBits, signed_magnitude, Checked, Allocator, fals
m_limbs = new_size;
}
}
BOOST_MP_FORCEINLINE void normalize() noexcept
BOOST_MP_FORCEINLINE constexpr void normalize() noexcept
{
limb_pointer p = limbs();
while ((m_limbs - 1) && !p[m_limbs - 1])
--m_limbs;
}
BOOST_MP_FORCEINLINE constexpr cpp_int_base() noexcept : m_data(), m_limbs(1), m_sign(false), m_internal(true), m_alias(false){}
BOOST_MP_FORCEINLINE cpp_int_base(const cpp_int_base& o) : base_type(o), m_limbs(o.m_alias ? o.m_limbs : 0), m_sign(o.m_sign), m_internal(o.m_alias ? false : true), m_alias(o.m_alias)
BOOST_MP_FORCEINLINE cpp_int_base(const cpp_int_base& o) : base_type(o), m_limbs(o.m_alias ? o.m_limbs : 0), m_sign(o.m_sign), m_internal(o.m_alias ? false : true), m_alias(o.m_alias)
{
if (m_alias)
{
Expand Down
19 changes: 12 additions & 7 deletions include/boost/multiprecision/cpp_int/literals.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
///////////////////////////////////////////////////////////////
// Copyright 2013 John Maddock. Distributed under the Boost
// Copyright 2013 John Maddock.
// Copyright 2026 Christopher Kormanyos
// Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt

Expand Down Expand Up @@ -255,21 +257,24 @@ constexpr typename boost::multiprecision::literals::detail::unsigned_cpp_int_lit
constexpr boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<Bits, Bits, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void> > BOOST_MP_LIT(_cppi, Bits)() \
{ \
using pt = typename boost::multiprecision::literals::detail::make_packed_value_from_str<STR...>::type; \
return boost::multiprecision::literals::detail::make_backend_from_pack< \
pt, \
boost::multiprecision::backends::cpp_int_backend<Bits, Bits, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void> >::value; \
using local_backend_type = boost::multiprecision::backends::cpp_int_backend<Bits, Bits, boost::multiprecision::signed_magnitude, boost::multiprecision::unchecked, void>; \
auto result { boost::multiprecision::literals::detail::make_backend_from_pack<pt, local_backend_type >::value }; \
result.normalize(); \
return result; \
} \
template <char... STR> \
constexpr boost::multiprecision::number<boost::multiprecision::backends::cpp_int_backend<Bits, Bits, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void> > BOOST_MP_LIT(_cppui, Bits)() \
{ \
using pt = typename boost::multiprecision::literals::detail::make_packed_value_from_str<STR...>::type; \
return boost::multiprecision::literals::detail::make_backend_from_pack< \
pt, \
boost::multiprecision::backends::cpp_int_backend<Bits, Bits, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void> >::value; \
using local_backend_type = boost::multiprecision::backends::cpp_int_backend<Bits, Bits, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>; \
auto result { boost::multiprecision::literals::detail::make_backend_from_pack<pt, local_backend_type >::value }; \
result.normalize(); \
return result; \
}

BOOST_MP_DEFINE_SIZED_CPP_INT_LITERAL(128)
BOOST_MP_DEFINE_SIZED_CPP_INT_LITERAL(256)
BOOST_MP_DEFINE_SIZED_CPP_INT_LITERAL(384)
BOOST_MP_DEFINE_SIZED_CPP_INT_LITERAL(512)
BOOST_MP_DEFINE_SIZED_CPP_INT_LITERAL(1024)
#undef BOOST_MP_LIT
Expand Down
1 change: 1 addition & 0 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,7 @@ test-suite misc :
[ run git_issue_734.cpp ]
[ run git_issue_743.cpp : : : [ check-target-builds ../config//has_float128 : <source>quadmath : <build>no ] ]
[ run git_issue_759.cpp : : : [ check-target-builds ../config//has_float128 : <source>quadmath : <build>no ] ]
[ run git_issue_766.cpp ]
[ compile git_issue_98.cpp :
[ check-target-builds ../config//has_float128 : <define>TEST_FLOAT128 <source>quadmath : ]
[ check-target-builds ../config//has_gmp : <define>TEST_GMP <source>gmp : ]
Expand Down
63 changes: 63 additions & 0 deletions test/git_issue_766.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
////////////////////////////////////////////////////////////////
// Copyright 2026 Christopher Kormanyos.
// Distributed under the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt
// or copy at https://www.boost.org/LICENSE_1_0.txt)

#include <boost/core/lightweight_test.hpp>
#include <boost/multiprecision/cpp_int.hpp>

namespace Mp = boost::multiprecision;
using namespace boost::multiprecision::literals;

using uint384_t = Mp::number<Mp::cpp_int_backend<384, 384, Mp::unsigned_magnitude, Mp::unchecked, void>, Mp::et_off>;
using int512_t = Mp::number<Mp::cpp_int_backend<512, 512, Mp::signed_magnitude, Mp::unchecked, void>, Mp::et_off>;

template <char... TStr>
constexpr auto operator""_u384() -> uint384_t
{
return operator""_cppui384 < TStr...>();
}

template <char... TStr>
constexpr auto operator""_i512() -> int512_t
{
return operator""_cppi512 < TStr...>();
}

auto main() -> int
{
{
constexpr auto value { 0x00000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111_u384 };
constexpr auto mask { 0x0000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_u384 };

constexpr auto masked { value & mask };

constexpr bool result_mask_is_ok { (value == masked) };
constexpr bool result_size_is_ok { (value.backend().size() == masked.backend().size()) };

static_assert(result_mask_is_ok, "Error: unexpected value results in non-equality");
static_assert(result_size_is_ok, "Error: unexpected size results in non-equality");

BOOST_TEST(result_mask_is_ok);
BOOST_TEST(result_size_is_ok);
}

{
constexpr auto value { 0x00000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111_i512 };
constexpr auto mask { 0x0000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_i512 };

constexpr auto masked { value & mask };

constexpr bool result_mask_is_ok { (value == masked) };
constexpr bool result_size_is_ok { (value.backend().size() == masked.backend().size()) };

static_assert(result_mask_is_ok, "Error: unexpected value results in non-equality");
static_assert(result_size_is_ok, "Error: unexpected size results in non-equality");

BOOST_TEST(result_mask_is_ok);
BOOST_TEST(result_size_is_ok);
}

return boost::report_errors();
}
Loading