20#include <xrpl/basics/mulDiv.h>
22#include <doctest/doctest.h>
34 auto result =
mulDiv(85, 20, 5);
36 CHECK(*result == 340);
37 result =
mulDiv(20, 85, 5);
39 CHECK(*result == 340);
41 result =
mulDiv(0, max - 1, max - 3);
44 result =
mulDiv(max - 1, 0, max - 3);
48 result =
mulDiv(max, 2, max / 2);
51 result =
mulDiv(max, 1000, max / 1000);
53 CHECK(*result == 1000000);
54 result =
mulDiv(max, 1000, max / 1001);
56 CHECK(*result == 1001000);
57 result =
mulDiv(max32 + 1, max32 + 1, 5);
59 CHECK(*result == 3689348814741910323);
62 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.