mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 20:03:03 +01:00
Slavomir Skopalik contributed IB_UDF_frac.
This commit is contained in:
parent
663df9012c
commit
6521e12aaf
@ -18,8 +18,10 @@
|
||||
* Changes made by Claudio Valderrama for the Firebird project
|
||||
* changes to substr and added substrlen
|
||||
* 2004.9.1 Claudio Valderrama, change some UDF's to be able to detect NULL.
|
||||
* 2004.12.5 Slavomir Skopalik contributed IB_UDF_frac.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "firebird.h"
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
@ -150,6 +152,15 @@ double EXPORT IB_UDF_floor( double *a)
|
||||
return (floor(*a));
|
||||
}
|
||||
|
||||
double EXPORT IB_UDF_frac(const double* x)
|
||||
{
|
||||
if (*x > 0)
|
||||
return *x - floor(*x);
|
||||
if (*x < 0)
|
||||
return *x - ceil(*x);
|
||||
return 0;
|
||||
}
|
||||
|
||||
double EXPORT IB_UDF_ln( double *a)
|
||||
{
|
||||
return (log(*a));
|
||||
@ -263,10 +274,6 @@ double EXPORT IB_UDF_rand()
|
||||
return ((float) rand() / (float) RAND_MAX);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
char *EXPORT IB_UDF_rpad( const char *s, long *a, const char *c)
|
||||
{
|
||||
if (!s || !c)
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
* All Rights Reserved.
|
||||
* Contributor(s): ______________________________________.
|
||||
* $Id: ib_udf2.sql,v 1.3 2004-11-03 14:16:57 fsg Exp $
|
||||
* $Id: ib_udf2.sql,v 1.4 2004-12-07 00:29:40 robocop Exp $
|
||||
* Revision 1.2 2000/11/28 06:47:52 fsg
|
||||
* Changed declaration of ascii_char in ib_udf.sql
|
||||
* to get correct result as proposed by Claudio Valderrama
|
||||
@ -298,6 +298,21 @@ DECLARE EXTERNAL FUNCTION floor
|
||||
RETURNS DOUBLE PRECISION BY VALUE
|
||||
ENTRY_POINT 'IB_UDF_floor' MODULE_NAME 'ib_udf';
|
||||
|
||||
/*****************************************
|
||||
*
|
||||
* f r a c
|
||||
*
|
||||
*****************************************
|
||||
*
|
||||
* Functional description:
|
||||
* Returns the fractional part of the argument.
|
||||
*
|
||||
*****************************************/
|
||||
DECLARE EXTERNAL FUNCTION frac
|
||||
DOUBLE PRECISION
|
||||
RETURNS DOUBLE PRECISION BY VALUE
|
||||
ENTRY_POINT 'IB_UDF_frac' MODULE_NAME 'ib_udf';
|
||||
|
||||
/*****************************************
|
||||
*
|
||||
* l n
|
||||
|
Loading…
Reference in New Issue
Block a user