diff --git a/cpp/src/round/round.cu b/cpp/src/round/round.cu index a13133dc0ec..b42c78fda8e 100644 --- a/cpp/src/round/round.cu +++ b/cpp/src/round/round.cu @@ -237,6 +237,9 @@ std::unique_ptr round_with(column_view const& input, using Type = device_storage_type_t; using FixedPointRoundFunctor = RoundFunctor; + if (input.type().scale() == -decimal_places) + return std::make_unique(input, stream, mr); + // if rounding to more precision than fixed_point is capable of, just need to rescale // note: decimal_places has the opposite sign of numeric::scale_type (therefore have to negate) if (input.type().scale() > -decimal_places) { diff --git a/cpp/tests/round/round_tests.cpp b/cpp/tests/round/round_tests.cpp index 242390ca59b..747e3122759 100644 --- a/cpp/tests/round/round_tests.cpp +++ b/cpp/tests/round/round_tests.cpp @@ -56,6 +56,19 @@ TYPED_TEST(RoundTestsFixedPointTypes, SimpleFixedPointTestHalfUpZero) CUDF_TEST_EXPECT_COLUMNS_EQUAL(expected, result->view()); } +TYPED_TEST(RoundTestsFixedPointTypes, SimpleFixedPointTestHalfUpZeroNoOp) +{ + using namespace numeric; + using decimalXX = TypeParam; + using RepType = cudf::device_storage_type_t; + using fp_wrapper = cudf::test::fixed_point_column_wrapper; + + auto const input = fp_wrapper{{1125, 1150, 1160, 1240, 1250, 1260}, scale_type{0}}; + auto const result = cudf::round(input); + + CUDF_TEST_EXPECT_COLUMNS_EQUAL(input, result->view()); +} + TYPED_TEST(RoundTestsFixedPointTypes, SimpleFixedPointTestHalfEvenZero) { using namespace numeric;