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

Function IntegerScalarToDoubleSafe

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

Source from the content-addressed store, hash-verified

503}
504
505Status IntegerScalarToDoubleSafe(PyObject* obj, double* out) {
506 int64_t value = 0;
507 RETURN_NOT_OK(UnboxIntegerAsInt64(obj, &value));
508
509 constexpr int64_t kDoubleMax = 1LL << 53;
510 constexpr int64_t kDoubleMin = -(1LL << 53);
511
512 if (value < kDoubleMin || value > kDoubleMax) {
513 return Status::Invalid("Integer value ", value, " is outside of the range exactly",
514 " representable by a IEEE 754 double precision value");
515 }
516 *out = static_cast<double>(value);
517 return Status::OK();
518}
519
520Status IntegerScalarToFloat32Safe(PyObject* obj, float* out) {
521 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