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

Function IntegerScalarToFloat32Safe

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

Source from the content-addressed store, hash-verified

518}
519
520Status IntegerScalarToFloat32Safe(PyObject* obj, float* out) {
521 int64_t value = 0;
522 RETURN_NOT_OK(UnboxIntegerAsInt64(obj, &value));
523
524 constexpr int64_t kFloatMax = 1LL << 24;
525 constexpr int64_t kFloatMin = -(1LL << 24);
526
527 if (value < kFloatMin || value > kFloatMax) {
528 return Status::Invalid("Integer value ", value, " is outside of the range exactly",
529 " representable by a IEEE 754 single precision value");
530 }
531 *out = static_cast<float>(value);
532 return Status::OK();
533}
534
535void DebugPrint(PyObject* obj) {
536 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