MCPcopy Create free account
hub / github.com/apache/arrow / MultiplyWithOverflowGeneric

Function MultiplyWithOverflowGeneric

cpp/src/arrow/util/int_util_overflow.h:108–121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106
107template <typename Int>
108[[nodiscard]] bool MultiplyWithOverflowGeneric(Int u, Int v, Int* out) {
109#if USE_CHECKED_ARITHMETIC_BUILTINS
110 return __builtin_mul_overflow(u, v, out);
111#else
112 if constexpr (sizeof(Int) < 4) {
113 using UpscaledInt = upscaled_int32_t<Int>;
114 auto r = static_cast<UpscaledInt>(u) * static_cast<UpscaledInt>(v);
115 *out = static_cast<Int>(r);
116 return r != *out;
117 } else {
118 return SafeIntMultiplyWithOverflow(u, v, out);
119 }
120#endif
121}
122
123template <typename Int>
124[[nodiscard]] bool DivideWithOverflowGeneric(Int u, Int v, Int* out) {

Callers 2

MultiplyWithOverflowFunction · 0.85
SerializeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected