1#include <xrpl/basics/mulDiv.h>
3#include <doctest/doctest.h>
15 auto result =
mulDiv(85, 20, 5);
17 CHECK(*result == 340);
18 result =
mulDiv(20, 85, 5);
20 CHECK(*result == 340);
22 result =
mulDiv(0, max - 1, max - 3);
25 result =
mulDiv(max - 1, 0, max - 3);
29 result =
mulDiv(max, 2, max / 2);
32 result =
mulDiv(max, 1000, max / 1000);
34 CHECK(*result == 1000000);
35 result =
mulDiv(max, 1000, max / 1001);
37 CHECK(*result == 1001000);
38 result =
mulDiv(max32 + 1, max32 + 1, 5);
40 CHECK(*result == 3689348814741910323);
43 result =
mulDiv(max - 1, max - 2, 5);
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::optional< std::uint64_t > mulDiv(std::uint64_t value, std::uint64_t mul, std::uint64_t div)
Return value*mul/div accurately.