Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/ydb-cpp-sdk/client/value/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ struct TDecimalValue {
std::string ToString() const;
TDecimalValue(const Ydb::Value& decimalValueProto, const TDecimalType& decimalType);
TDecimalValue(const std::string& decimalString, uint8_t precision, uint8_t scale);
TDecimalValue(uint64_t low, int64_t hi, uint8_t precision, uint8_t scale);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А зачем такой конструктор хочется иметь? Вроде все поля публичные, должна работать uniform иницализация


TDecimalType DecimalType_;
uint64_t Low_;
Expand Down
7 changes: 7 additions & 0 deletions src/client/value/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,13 @@ TDecimalValue::TDecimalValue(const std::string& decimalString, ui8 precision, ui
Hi_ = *(int64_t*)(buf + 8);
}

TDecimalValue::TDecimalValue(uint64_t low, int64_t hi, uint8_t precision, uint8_t scale)
: DecimalType_(precision, scale)
, Low_(low)
, Hi_(hi)
{
}

std::string TDecimalValue::ToString() const {
NYdb::NDecimal::TInt128 val = NYdb::NDecimal::FromHalfs(Low_, Hi_);
return NYdb::NDecimal::ToString(val, DecimalType_.Precision, DecimalType_.Scale);
Expand Down
Loading