From 1853a740130f557f787d2c97dc9b42b1e410722b Mon Sep 17 00:00:00 2001 From: Vitaly Stoyan Date: Mon, 28 Oct 2024 21:13:43 +0300 Subject: [PATCH] init --- ydb/library/yql/public/decimal/ut/yql_decimal_ut.cpp | 1 + ydb/library/yql/public/decimal/yql_decimal.cpp | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/ydb/library/yql/public/decimal/ut/yql_decimal_ut.cpp b/ydb/library/yql/public/decimal/ut/yql_decimal_ut.cpp index 8ff43e997c3b..b7defdece080 100644 --- a/ydb/library/yql/public/decimal/ut/yql_decimal_ut.cpp +++ b/ydb/library/yql/public/decimal/ut/yql_decimal_ut.cpp @@ -215,6 +215,7 @@ Y_UNIT_TEST_SUITE(TYqlDecimalTest) { UNIT_ASSERT(FromStringEx("-1e-99", 10, 2) == 0); UNIT_ASSERT(FromStringEx("-510e-3", 1, 0) == -1); UNIT_ASSERT(FromStringEx("+99E3", 5, 0) == 99000); + UNIT_ASSERT(FromStringEx("2.1E-130", 35, 2) == 0); } Y_UNIT_TEST(TestFormStringExInvalidValues) { diff --git a/ydb/library/yql/public/decimal/yql_decimal.cpp b/ydb/library/yql/public/decimal/yql_decimal.cpp index 737691e10ce3..711638ef9825 100644 --- a/ydb/library/yql/public/decimal/yql_decimal.cpp +++ b/ydb/library/yql/public/decimal/yql_decimal.cpp @@ -10,6 +10,10 @@ namespace NDecimal { static const TUint128 Ten(10U); TUint128 GetDivider(ui8 scale) { + if (scale > MaxPrecision) { + return Inf(); + } + TUint128 d(1U); while (scale--) d *= Ten;