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

Method FromPositiveRealApprox

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

Source from the content-addressed store, hash-verified

356
357 template <typename Real>
358 static Result<Decimal64> FromPositiveRealApprox(Real real, int32_t precision,
359 int32_t scale) {
360 const auto x = std::nearbyint(real * PowerOfTen<Real>(scale));
361 const auto max_abs = PowerOfTen<Real>(precision);
362 if (x <= -max_abs || x >= max_abs) {
363 return OverflowError(real, precision, scale);
364 }
365
366 return Decimal64(static_cast<int64_t>(x));
367 }
368
369 template <typename Real>
370 static Real ToRealPositiveNoSplit(const Decimal64& decimal, int32_t scale) {

Callers

nothing calls this directly

Calls 1

Decimal64Function · 0.70

Tested by

no test coverage detected