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

Function IntegerScalarToFloat32Safe

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

Source from the content-addressed store, hash-verified

495}
496
497Status IntegerScalarToFloat32Safe(PyObject* obj, float* out) {
498 int64_t value = 0;
499 RETURN_NOT_OK(UnboxIntegerAsInt64(obj, &value));
500
501 constexpr int64_t kFloatMax = 1LL << 24;
502 constexpr int64_t kFloatMin = -(1LL << 24);
503
504 if (value < kFloatMin || value > kFloatMax) {
505 return Status::Invalid("Integer value ", value, " is outside of the range exactly",
506 " representable by a IEEE 754 single precision value");
507 }
508 *out = static_cast<float>(value);
509 return Status::OK();
510}
511
512void DebugPrint(PyObject* obj) {
513 std::string repr = PyObject_StdStringRepr(obj);

Callers 1

ConvertMethod · 0.85

Calls 3

UnboxIntegerAsInt64Function · 0.85
InvalidFunction · 0.50
OKFunction · 0.50

Tested by

no test coverage detected