round, i64round
<< right | FB 2.5 Language Reference | rpad >>
round
, i64round
Library: fbudf
Added in: 1.0 (Win), 1.5 (Linux)
Changed in: 1.5, 2.1.3
Better alternative: Internal function ROUND()
Description
These functions return the whole number that is nearest to their (scaled numeric
/decimal
) argument. They do not work with floats or doubles.
Result type: INTEGER
/ NUMERIC(18,4)
Syntax
round (number) i64round (bignumber)
Caution: Halves are always rounded upward, i.e. away from zero for positive numbers and toward zero for negative numbers. For instance, 3.5 is rounded to 4, but -3.5 is rounded to -3. The internal function ROUND
, available since Firebird 2.1, rounds all halves away from zero.
Declarations
In Firebird 1.0.x, the entry point for both functions is round
:
DECLARE EXTERNAL FUNCTION Round INT BY DESCRIPTOR, INT BY DESCRIPTOR RETURNS PARAMETER 2 ENTRY_POINT 'round' MODULE_NAME 'fbudf' DECLARE EXTERNAL FUNCTION i64Round NUMERIC(18,4) BY DESCRIPTOR, NUMERIC(18,4) BY DESCRIPTOR RETURNS PARAMETER 2 ENTRY_POINT 'round' MODULE_NAME 'fbudf'
In Firebird 1.5, the entry point has been renamed to fbround
:
DECLARE EXTERNAL FUNCTION Round INT BY DESCRIPTOR, INT BY DESCRIPTOR RETURNS PARAMETER 2 ENTRY_POINT 'fbround' MODULE_NAME 'fbudf' DECLARE EXTERNAL FUNCTION i64Round NUMERIC(18,4) BY DESCRIPTOR, NUMERIC(18,4) BY DESCRIPTOR RETURNS PARAMETER 2 ENTRY_POINT 'fbround' MODULE_NAME 'fbudf'
If you move an existing database from Firebird 1.0.x to 1.5 or higher, drop any existing *round
and *truncate
declarations and declare them anew, using the updated entry point names. From Firebird 2.0 onward you can also perform this update with ALTER EXTERNAL FUNCTION
.
back to top of page
<< right | FB 2.5 Language Reference | rpad >>