File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 2424#include < bit>
2525#include < cassert>
2626#include < charconv>
27+ #include < climits>
2728#include < cmath>
2829#include < cstddef>
2930#include < cstdint>
31+ #include < cstring>
3032#include < format>
3133#include < iomanip>
3234#include < iostream>
@@ -1338,6 +1340,12 @@ double Decimal::ToDouble(int32_t scale) const {
13381340 return DecimalRealConversion::ToReal<double >(*this , scale);
13391341}
13401342
1343+ std::array<uint8_t , Decimal::kByteWidth > Decimal::ToBytes () const {
1344+ std::array<uint8_t , kByteWidth > out{{0 }};
1345+ memcpy (out.data (), data_.data (), kByteWidth );
1346+ return out;
1347+ }
1348+
13411349// Unary operators
13421350ICEBERG_EXPORT Decimal operator -(const Decimal& operand) {
13431351 Decimal result (operand.high (), operand.low ());
Original file line number Diff line number Diff line change @@ -168,7 +168,7 @@ class ICEBERG_EXPORT Decimal {
168168
169169 // / \brief Whether this number fits in the given precision
170170 // /
171- // / Return true if the number of significant digits is less or equal to `precision`.
171+ // / Returns true if the number of significant digits is less or equal to `precision`.
172172 bool FitsInPrecision (int32_t precision) const ;
173173
174174 // / \brief Convert to a floating-point number (scaled)
@@ -193,12 +193,8 @@ class ICEBERG_EXPORT Decimal {
193193 return reinterpret_cast <const uint8_t *>(data_.data ());
194194 }
195195
196- // / \brief Return the raw bytes of the value in native-endian byte order.
197- std::array<uint8_t , kByteWidth > ToBytes () const {
198- std::array<uint8_t , kByteWidth > out{{0 }};
199- memcpy (out.data (), data_.data (), kByteWidth );
200- return out;
201- }
196+ // / \brief Returns the raw bytes of the value in native-endian byte order.
197+ std::array<uint8_t , kByteWidth > ToBytes () const ;
202198
203199 // / \brief Returns 1 if positive or zero, -1 if strictly negative.
204200 int64_t Sign () const { return 1 | (static_cast <int64_t >(data_[kHighIndex ]) >> 63 ); }
You can’t perform that action at this time.
0 commit comments