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