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

Function IntegerScalarToDoubleSafe

python/pyarrow/src/arrow/python/helpers.cc:482–495  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

480}
481
482Status IntegerScalarToDoubleSafe(PyObject* obj, double* out) {
483 int64_t value = 0;
484 RETURN_NOT_OK(UnboxIntegerAsInt64(obj, &value));
485
486 constexpr int64_t kDoubleMax = 1LL << 53;
487 constexpr int64_t kDoubleMin = -(1LL << 53);
488
489 if (value < kDoubleMin || value > kDoubleMax) {
490 return Status::Invalid("Integer value ", value, " is outside of the range exactly",
491 " representable by a IEEE 754 double precision value");
492 }
493 *out = static_cast<double>(value);
494 return Status::OK();
495}
496
497Status IntegerScalarToFloat32Safe(PyObject* obj, float* out) {
498 int64_t value = 0;

Callers 1

ConvertMethod · 0.85

Calls 3

UnboxIntegerAsInt64Function · 0.85
InvalidFunction · 0.50
OKFunction · 0.50

Tested by

no test coverage detected