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

Method FromPositiveRealApprox

cpp/src/arrow/util/decimal.cc:291–300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289
290 template <typename Real>
291 static Result<Decimal32> FromPositiveRealApprox(Real real, int32_t precision,
292 int32_t scale) {
293 const auto x = std::nearbyint(real * PowerOfTen<Real>(scale));
294 const auto max_abs = PowerOfTen<Real>(precision);
295 if (x <= -max_abs || x >= max_abs) {
296 return OverflowError(real, precision, scale);
297 }
298
299 return Decimal32(static_cast<int32_t>(x));
300 }
301
302 template <typename Real>
303 static Real ToRealPositiveNoSplit(const Decimal32& decimal, int32_t scale) {

Callers

nothing calls this directly

Calls 1

Decimal32Function · 0.70

Tested by

no test coverage detected