JonSnow1807 commented on issue #48003:
URL: https://github.com/apache/arrow/issues/48003#issuecomment-6751889563

   Proposal before a PR: add `multiply(duration, float64)`, `multiply(float64, 
duration)` and `divide(duration, float64)`, plus the `_checked` variants, 
returning a duration in the same unit. No `float / duration`. Results round to 
nearest with ties to even (5 s × 1.5 = 8 s), like Python’s timedelta, rok’s 
`round_to_multiple` sketch and Arrow’s float-to-decimal cast. It also keeps the 
issue’s round trip exact: for 1 to 100000 ns, truncation loses one unit up to 
6496 times, rounding loses none. NaN, infinite or out-of-range results are an 
error in both variants, since converting them to int64 is undefined behaviour 
(numpy gives NaT on x86 but INT64_MAX on ARM). Division by zero errors like 
`divide(duration, int64)`. Nulls give null. float32/float16 are cast to 
float64. The tradeoff: numpy, pandas and polars truncate instead.
   
   Does rounding ties to even (rather than numpy’s truncation) and erroring 
rather than returning null in the non-checked variants sound right? I have an 
implementation ready if so.
   


-- 
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]

Reply via email to