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

Function DivideWithOverflowGeneric

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

Source from the content-addressed store, hash-verified

122
123template <typename Int>
124[[nodiscard]] bool DivideWithOverflowGeneric(Int u, Int v, Int* out) {
125 if (v == 0) {
126 *out = Int{};
127 return true;
128 }
129 if constexpr (std::is_signed_v<Int>) {
130 constexpr auto kMin = std::numeric_limits<Int>::min();
131 if (u == kMin && v == -1) {
132 *out = kMin;
133 return true;
134 }
135 }
136 *out = u / v;
137 return false;
138}
139
140template <typename Int>
141[[nodiscard]] bool ModuloWithOverflowGeneric(Int u, Int v, Int* out) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected