21.10.2013 Views

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Better alternative: Internal function TANH()<br />

External functions (UDFs)<br />

Description: Returns the hyperbolic tangent of the argument.<br />

Result type: DOUBLE PRECISION<br />

Syntax:<br />

tanh (number)<br />

Declaration:<br />

DECLARE EXTERNAL FUNCTION tanh<br />

DOUBLE PRECISION<br />

RETURNS DOUBLE PRECISION BY VALUE<br />

ENTRY_POINT 'IB_UDF_tanh' MODULE_NAME 'ib_udf'<br />

Library: fbudf<br />

Added in: 1.0 (Win), 1.5 (Linux)<br />

Changed in: 1.5, <strong>2.1</strong>.3<br />

Better alternative: Internal function TRUNC()<br />

truncate, i64truncate<br />

Description: These functions return the whole-number portion of their (scaled numeric/decimal) argument. They<br />

do not work with floats or doubles.<br />

Result type: INTEGER / NUMERIC(18)<br />

Syntax:<br />

truncate (number)<br />

i64truncate (bignumber)<br />

Declarations:<br />

Caution<br />

Both functions round to the nearest whole number that is lower than or equal to the argument. This means that<br />

negative numbers are also “truncated” downward. For instance, truncate(-2.37) returns -3. The internal<br />

function TRUNC, available since <strong>Firebird</strong> <strong>2.1</strong>, always truncates toward zero.<br />

Bug alert<br />

Contrary to what's mentioned above, in versions <strong>2.1</strong>, <strong>2.1</strong>.1 and <strong>2.1</strong>.2 anything between -1 and 0 is truncated to<br />

0. This anomaly has been corrected in <strong>Firebird</strong> <strong>2.1</strong>.3 and above.<br />

In <strong>Firebird</strong> 1.0.x, the entry point for both functions is truncate:<br />

195

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!