[ 
https://issues.apache.org/jira/browse/ARROW-12744?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17370408#comment-17370408
 ] 

Eduardo Ponce commented on ARROW-12744:
---------------------------------------

The current implementation follows a *rounding with multiple* approach which is 
more general/flexible than *ndigits* parameter in [Python 
round|https://docs.python.org/3.7/library/functions.html#round] and *decimals* 
parameter in 
[NumPy|https://numpy.org/doc/stable/reference/generated/numpy.around.html#numpy.around],
 [pandas 
round|https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.round.html],
 and 
[MySQL|https://dev.mysql.com/doc/refman/5.7/en/mathematical-functions.html#function_round].

The following are comments on round APIs:
 * The *decimals* parameter name in NumPy and pandas seems counter-intuitive in 
that when it is a negative value it corresponds to the non-decimal part of the 
value. IMHO *ndigits* is a more suitable name.
 * *rounding with multiple* bypasses the need to calculate pow(10, decimals). 
Although, I expect the other software use a LUT table for power(10, x) which is 
better. For example, MySQL limits *|decimals| < 30*.
 * The *decimals* parameter only supports rounding to powers of 10.

We can also include two variants of rounding functions (similar to Excel)
 * *round(x, ndigits)*
 * *mround(x, multiple)*

Any comments or suggestions are welcomed.

> [C++][Compute] Add rounding kernel
> ----------------------------------
>
>                 Key: ARROW-12744
>                 URL: https://issues.apache.org/jira/browse/ARROW-12744
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: C++
>            Reporter: Ian Cook
>            Assignee: Eduardo Ponce
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> Kernel to round an array of floating point numbers. Should return an array of 
> the same type as the input. Should have an option to control how many digits 
> after the decimal point (default value 0 meaning round to the nearest 
> integer).
> Midpoint values (e.g. 0.5 rounded to nearest integer) should round away from 
> zero (up for positive numbers, down for negative numbers).



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to