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

Method Call

cpp/src/arrow/compute/kernels/scalar_round.cc:544–569  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

542
543 template <typename T = ArrowType, typename CType = typename TypeTraits<T>::CType>
544 enable_if_floating_value<CType> Call(KernelContext* ctx, CType arg, Status* st) const {
545 // Do not process Inf or NaN because they will trigger the overflow error at end of
546 // function.
547 if (!std::isfinite(arg)) {
548 return arg;
549 }
550 auto round_val = arg / multiple;
551 auto frac = round_val - std::floor(round_val);
552 if (frac != T(0)) {
553 // Use std::round() if in tie-breaking mode and scaled value is not 0.5.
554 if ((kRoundMode >= RoundMode::HALF_DOWN) && (frac != T(0.5))) {
555 round_val = std::round(round_val);
556 } else {
557 round_val = RoundImpl<CType, kRoundMode>::Round(round_val);
558 }
559 round_val *= multiple;
560 if (!std::isfinite(round_val)) {
561 *st = Status::Invalid("overflow occurred during rounding");
562 return arg;
563 }
564 } else {
565 // If scaled value is an integer, then no rounding is needed.
566 round_val = arg;
567 }
568 return round_val;
569 }
570};
571
572template <typename ArrowType, RoundMode kRoundMode>

Callers

nothing calls this directly

Calls 2

RoundClass · 0.70
InvalidFunction · 0.50

Tested by

no test coverage detected