mingmwang commented on issue #6278:
URL: 
https://github.com/apache/arrow-datafusion/issues/6278#issuecomment-1541158352

   > > I think the major problem is that the `i256` math operation is not 
efficient.
   > 
   > As I mentioned above ([#6278 
(comment)](https://github.com/apache/arrow-datafusion/issues/6278#issuecomment-1539232844)),
 `divide_and_round` spent too much time on i256 operations, especially 
`wrapping_div` and `wrapping_rem`. We currently round back to BigInt for these 
math operations which are slow.
   > 
   > Implementing native `wrapping_div` and `wrapping_rem` will help speeding 
up these operations.
   > 
   > I will look into it and try to implement them.
   > 
   > > And the logic in the method `multiply_fixed_point()` in arrow-rs is not 
consistent.
   > > `If required_scale == product_scale`, it still uses `i128` for 
multiply(can still overflow) `if product_scale > required_scale`, use `i256` 
for multiply and div, why ??
   > 
   > It is not inconsistent. It is for allowing precision-loss decimal 
multiplication. Our kernels basically allow overflow.
   > 
   > If `required_scale` equals to `product_scale`, it won't lose precision, so 
we can use i128. If `product_scale` is larger than `required_scale`, the 
multiplication will lose precision, we need to multiply in i256 and divide the 
result to get the result with less precision.
   
   Could you please explain a bit, why if the `product_scale` is larger than 
`required_scale`,   we need to multiply in `i256` ?
   Can we multiply in `i128` and divide the gap back ?
   


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