• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

libbitcoin / libbitcoin-system / 9324917697

31 May 2024 10:10PM UTC coverage: 82.819% (+0.09%) from 82.732%
9324917697

Pull #1469

github

web-flow
Merge 0155ccfba into 434772ab9
Pull Request #1469: Optimize size computations, use ceilinged_add, style.

71 of 85 new or added lines in 7 files covered. (83.53%)

7 existing lines in 2 files now uncovered.

9848 of 11891 relevant lines covered (82.82%)

4796079.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.43
/include/bitcoin/system/impl/math/multiplication.ipp
1
/**
2
 * Copyright (c) 2011-2023 libbitcoin developers (see AUTHORS)
3
 *
4
 * This file is part of libbitcoin.
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU Affero General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU Affero General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Affero General Public License
17
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
#ifndef LIBBITCOIN_SYSTEM_MATH_MULTIPLICATION_IPP
20
#define LIBBITCOIN_SYSTEM_MATH_MULTIPLICATION_IPP
21

22
#include <bitcoin/system/define.hpp>
23
#include <bitcoin/system/math/cast.hpp>
24
#include <bitcoin/system/math/limits.hpp>
25
#include <bitcoin/system/math/overflow.hpp>
26

27
namespace libbitcoin {
28
namespace system {
29

30
template <typename Integer, if_integer<Integer>>
31
constexpr bool is_multiple(Integer product, Integer value) NOEXCEPT
816,248✔
32
{
33
    return is_nonzero(value) ? is_zero(product % value) : is_zero(product);
816,248✔
34
}
35

36
template <typename Integer, if_integer<Integer>>
37
constexpr bool is_product(Integer product, Integer left,
816✔
38
    Integer right) NOEXCEPT
39
{
40
    return (is_zero(left) || is_zero(right)) ? is_zero(product) :
816✔
41
        is_zero(product % left) && ((product / left) == right);
816✔
42
}
43

44
template <typename Unsigned, if_unsigned_integer<Unsigned>>
UNCOV
45
constexpr Unsigned ceilinged_multiply(Unsigned left, Unsigned right) NOEXCEPT
×
46
{
47
    return is_multiply_overflow(left, right) ? maximum<Unsigned> :
UNCOV
48
        depromote<Unsigned>(left * right);
×
49
}
50

51
} // namespace system
52
} // namespace libbitcoin
53

54
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc