scovich opened a new pull request, #8357:
URL: https://github.com/apache/arrow-rs/pull/8357
# Which issue does this PR close?
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases. You can
link an issue to this PR using the GitHub syntax.
- Closes #NNN.
# Rationale for this change
Historically, `Variant::as_fXX` methods don't even try to cast int values as
floating point, which is counter-intuitive.
# What changes are included in this PR?
Allow lossless casting of variant integer values to variant floating point
values, by a naive determination of precision:
* Every floating point number has some number of bits of precision
* 53 (double)
* 24 (single)
* 11 (half)
* Any integer that fits entirely inside the target floating point type's
precision can be converted losslessly
* This produces an intuitive result: "too big" numbers fail to convert,
while "small enough" numbers do convert.
* This is a sufficient but _not_ a necessary condition.
* Technically, wider integer can be represented losslessly as well, as
long as they have enough trailing zeros
* It's unclear whether allowing those wider values to cast is actually
helpful in practice, because only 1 in 2**k values can cast (where k is the
number of bits of excess precision); it would certainly make input testing more
expensive.
# Are these changes tested?
New unit tests and doc tests.
# Are there any user-facing changes?
Yes. Values that failed to cast before now succeed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]