mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
This change renames all occurrences of `namespace ripple` and `ripple::` to `namespace xrpl` and `xrpl::`, respectively, as well as the names of test suites. It also provides a script to allow developers to replicate the changes in their local branch or fork to avoid conflicts.
27 lines
669 B
C++
27 lines
669 B
C++
#ifndef XRPL_BASICS_MULDIV_H_INCLUDED
|
|
#define XRPL_BASICS_MULDIV_H_INCLUDED
|
|
|
|
#include <cstdint>
|
|
#include <limits>
|
|
#include <optional>
|
|
|
|
namespace xrpl {
|
|
auto constexpr muldiv_max = std::numeric_limits<std::uint64_t>::max();
|
|
|
|
/** Return value*mul/div accurately.
|
|
Computes the result of the multiplication and division in
|
|
a single step, avoiding overflow and retaining precision.
|
|
Throws:
|
|
None
|
|
Returns:
|
|
`std::optional`:
|
|
`std::nullopt` if the calculation overflows. Otherwise, `value * mul
|
|
/ div`.
|
|
*/
|
|
std::optional<std::uint64_t>
|
|
mulDiv(std::uint64_t value, std::uint64_t mul, std::uint64_t div);
|
|
|
|
} // namespace xrpl
|
|
|
|
#endif
|