Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: improve the ROUND and EXP functions.
Prior to this patch the computation would take too long or too much memory if EXP was given an argument too large or if the 2nd ROUND argument was negative with a large absolute value. This patch addresses this issue by limiting the range of acceptable arguments (1024 for EXP, anything that causes more than 2000 extra "0" digits to be appended on the right for ROUND). It improves both functions as follows: - a negative ROUND scale is now supported as in PostgreSQL and Oracle; this rounds to positions on the left of the decimal separator. - the ROUND function for floats is now performed on floats directly, instead of using Printf/ParseFloat as previously (faster). - the ROUND function for decimals is now faster if the 2nd argument is negative and its absolute value is larger than the number of digits in the 1st argument on the left of its decimal separator. - ROUND for both floats and decimal now use half to even rounding, also called unbiased rounding or bankers' rounding.
- Loading branch information
Showing
3 changed files
with
133 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters