Subject UDF on DOUBLE PRECISION returns wrong values
Author lutterot
Hello!

I am writing some UDFs in C and encountered a problem when receiving a
DOUBLE PRECISION value as argument. I am using Firebird version
2.0.1.12855.
The following UDF does not return the right results:

DECLARE EXTERNAL FUNCTION DOUBLE_TO_DOUBLE
Double precision BY DESCRIPTOR
RETURNS Double precision
ENTRY_POINT 'double_to_double'
MODULE_NAME 'mylib';

char* double_to_double(PARAMDSC* par)
{
if(!par || (par->dsc_flags & DSC_null)) return 0;
char* value = par->dsc_address;
char* result = ib_util_malloc(8);

result[0] = value[0];
result[1] = value[1];
result[2] = value[2];
result[3] = value[3];
result[4] = value[4];
result[5] = value[5];
result[6] = value[6];
result[7] = value[7];
return result;
}

The UDF should just return the same double value that it was give to.
However, it doesn't. For small double arguments the UDF always returns
zero. For larger or longer ones the return values get weird.
Am I doing a mistake here?

Thank you,
Christof