MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / MulCompare

Function MulCompare

src/test/fuzz/feefrac.cpp:49–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47}
48
49std::strong_ordering MulCompare(int64_t a1, int64_t a2, int64_t b1, int64_t b2)
50{
51 // Compute and compare signs.
52 int sign_a = (a1 == 0 ? 0 : a1 < 0 ? -1 : 1) * (a2 == 0 ? 0 : a2 < 0 ? -1 : 1);
53 int sign_b = (b1 == 0 ? 0 : b1 < 0 ? -1 : 1) * (b2 == 0 ? 0 : b2 < 0 ? -1 : 1);
54 if (sign_a != sign_b) return sign_a <=> sign_b;
55
56 // Compute absolute values of products.
57 auto mul_abs_a = Abs256(a1) * Abs256(a2), mul_abs_b = Abs256(b1) * Abs256(b2);
58
59 // Compute products of absolute values.
60 if (sign_a < 0) {
61 return mul_abs_b <=> mul_abs_a;
62 } else {
63 return mul_abs_a <=> mul_abs_b;
64 }
65}
66
67} // namespace
68

Callers 1

FUZZ_TARGETFunction · 0.85

Calls 1

Abs256Function · 0.85

Tested by

no test coverage detected