20 #include <ripple/basics/mulDiv.h>
21 #include <ripple/beast/unit_test.h>
33 auto result =
mulDiv(85, 20, 5);
34 BEAST_EXPECT(result.first && result.second == 340);
35 result =
mulDiv(20, 85, 5);
36 BEAST_EXPECT(result.first && result.second == 340);
38 result =
mulDiv(0, max - 1, max - 3);
39 BEAST_EXPECT(result.first && result.second == 0);
40 result =
mulDiv(max - 1, 0, max - 3);
41 BEAST_EXPECT(result.first && result.second == 0);
43 result =
mulDiv(max, 2, max / 2);
44 BEAST_EXPECT(result.first && result.second == 4);
45 result =
mulDiv(max, 1000, max / 1000);
46 BEAST_EXPECT(result.first && result.second == 1000000);
47 result =
mulDiv(max, 1000, max / 1001);
48 BEAST_EXPECT(result.first && result.second == 1001000);
49 result =
mulDiv(max32 + 1, max32 + 1, 5);
50 BEAST_EXPECT(result.first && result.second == 3689348814741910323);
53 result =
mulDiv(max - 1, max - 2, 5);
54 BEAST_EXPECT(!result.first && result.second == max);