meta data for this page
F_ZAHLRUNDEN, F_ROUNDCOMMON
compatibility FreeUDFLib AvERP, GrUDF
input/output-compatibility to rFunc (ROUND)
Entrypoint zahlrunden compatible with UTF-8
Inputs/Outputs
Input DOUBLE floatingpoint to be round INTEGER number of digits to be round Output DOUBLE floatingpoint rounded (trading method)
Syntax
Round-to-nearest. Described in German standard DIN 1333. From Wikipedia [[http://en.wikipedia.org/wiki/Rounding]]: This method is commonly used, for example in accounting. It is the one generally taught in basic mathematics classes. * Decide which is the last digit to keep. * Increase it by 1 if the next digit is 5 or more (this is called rounding up) * Leave it the same if the next digit is 4 or less (this is called rounding down) Examples: * 3.044 rounded to hundredths is 3.04 (because the next digit, 4, is less than 5). * 3.046 rounded to hundredths is 3.05 (because the next digit, 6, is 5 or more). * 3.0447 rounded to hundredths is 3.04 (because the next digit, 4, is less than 5). Negative numbers are rounded like their absolute values: * −2,1349 to −2,13 € * −2,1350 to −2,14 € TestSQL SELECT 14.5 AS ISCORRECT, F_ZAHLRUNDEN(14.4935, 1) FROM RDB$DATABASE; SELECT 14.49 AS ISCORRECT, F_ZAHLRUNDEN(14.4935, 2) FROM RDB$DATABASE; SELECT 14.494 AS ISCORRECT, F_ZAHLRUNDEN(14.4935, 3) FROM RDB$DATABASE; SELECT -14.494 AS ISCORRECT, F_ZAHLRUNDEN(-14.4935, 3) FROM RDB$DATABASE; SELECT 14.494 AS ISCORRECT, F_ZAHLRUNDEN(14.4936, 3) FROM RDB$DATABASE; SELECT 14.4935 AS ISCORRECT, F_ZAHLRUNDEN(14.4935, 6) FROM RDB$DATABASE; SELECT 40.43 AS ISCORRECT, F_ZAHLRUNDEN(40.425, 2) FROM RDB$DATABASE; SELECT 40.42 AS ISCORRECT, F_ZAHLRUNDEN(40.4242, 2) FROM RDB$DATABASE; SELECT 40.42 AS ISCORRECT, F_ZAHLRUNDEN(40.4246, 2) FROM RDB$DATABASE; SELECT 75.15 AS ISCORRECT, F_ZAHLRUNDEN(395.50 * (19.00 / 100),2) FROM RDB$DATABASE; SELECT NULL AS ISCORRECT, F_ZAHLRUNDEN(NULL, NULL) FROM RDB$DATABASE;