Hive's bronze function? Also called Gauss rounding or banker rounding
What is Gauss rounding or banker rounding?
The rounding mode that rounds to the nearest number. If the distance from two adjacent numbers is equal, round to the adjacent even number. If the number on the left of the discarded part is an odd number, the number on the left is increased by 1, and if it is an even number, the number on the left remains unchanged.
Example: bronze(2.5) = 2, bround(3.5) = 4.
The round and bronze functions of hive are as follows
Return type | function | description |
---|---|---|
DOUBLE | round(DOUBLE a) | Returns the rounded BIGINT value of a. |
DOUBLE | round(DOUBLE a, INT d) | Return a rounded to d places after the decimal point. |
DOUBLE | bround(DOUBLE a) | Use HALF_EVEN rounding mode (as of Hive 1.3.0, 2.0.0 ) to return the rounded BIGINT value of a. Also called Gaussian rounding or banker's rounding. Example: bronze(2.5) = 2, bround(3.5) = 4. |
DOUBLE | bround(DOUBLE a, INT d) | Use HALF_EVEN rounding mode (as of Hive 1.3.0, 2.0.0 ) to return a rounded to d decimal places. Example: bronze(8.25, 1) = 8.2, bround(8.35, 1) = 8.4. |