bea.com | products | dev2dev | support | askBEA

Download Docs | Site Map | Glossary
Search

Building Queries and Data Views

Numeric Functions

Numeric functions operate on numeric data types. The following numeric functions are available:

- xf:ceiling

- xf:floor

- xf:round

- xfext:decimal-round

- xfext:decimal-truncate

xf:ceiling

Returns the smallest (closest to negative infinity) integer that is not smaller than the source value.

Data Types

- Input data type: xs:double?

- Returned data type: xs:integer?

Notes

If the argument is an empty list, the function returns an empty list.

XQuery Specification Compliance

Conforms to the current specification.

Examples

- xf:ceiling(38.3) returns the integer value 39.

- xf:ceiling(38) returns the integer value 38.

- xf:ceiling(-3.3) returns the integer value -3.

- xf:ceiling("38.3") generates a compile-time error because the parameter is a string and not a numeric value.

xf:floor

Returns the largest (closest to positive infinity) integer that is not greater than the source value.

Data Types

- Input data type: xs:double?

- Returned data type: xs:integer?

Notes

If the argument is an empty list, the function returns an empty list.

XQuery Specification Compliance

Conforms to the current specification.

Examples

- xf:floor(38.3) returns the integer value 38.

- xf:floor(38) returns the integer value 38.

- xf:floor(-3.3) returns the integer value -4.

- xf:floor("38.3") generates a compile-time error because the parameter is a string and not a numeric value.

xf:round

Returns the integer that is closest to the source value.

Data Types

- Input data type: xs:double?

- Returned data type: xs:integer?

Notes

Round(x) produces the same result as the Floor function(x+0.5). If there are two such numbers, returns the one that is closest to +INF.

If the argument is +INF, returns +INF.

If the argument is -INF, returns -INF.

If the argument is +0, returns +0.

If the source value is an empty list, the function returns an empty list.

XQuery Specification Compliance

Liquid Data does not support not-a-number (NaN) or -0.

Examples

- xf:round(3) returns the integer value 3.

- xf:round(3.3) returns the integer value 3.

- xf:round(3.5) returns the integer value 4.

- xf:round(3.7) returns the integer value 4.

- xf:round(-3.3) returns the integer value -3.

- xf:round(-3.5) returns the integer value -3.

- xf:round(-3.7) returns the integer value -4.

- xf:round(-0) returns the integer value 0.

- xf:round("3.3") generates an error because the parameter is a string and not a numeric value.

xfext:decimal-round

Returns a decimal value rounded to the specified precision (scale).

Data Types

- dec - Input data type: xs:decimal?

- scale - Input data type: xs:integer?

- Returned data type: xs:decimal?

Notes

The scale input is the precision with which to round the decimal input. A scale value of 1 rounds the input to tenths, a scale value of 2 rounds it to hundreths, and so on.

XQuery Specification Compliance

This is an extended function and is not part of the XQuery specification.

Examples

- xfext:decimal-round(127.444, 2) returns 127.44.

- xfext:decimal-round(0.1234567, 6) returns 0.123457.

xfext:decimal-truncate

Returns a decimal value truncated to the specified precision (scale).

Data Types

- dec - Input data type: xs:decimal?

- scale - Input data type: xs:integer?

- Returned data type: xs:decimal?

Notes

The scale input is the precision with which to truncate the decimal input. A scale value of 1 truncates the input to tenths, a scale value of 2 truncates it to hundreths, and so on.

XQuery Specification Compliance

This is an extended function and is not part of the XQuery specification.

Examples

- xfext:decimal-truncate(127.444, 2) returns 127.44.

- xfext:decimal-truncate(0.1234567, 6) returns 0.123456.