|Subject||RE: [firebird-support] Udf and Double Field|
> Hi,two things you can try.
> I am using firebird 1.5.1
> I have written an udf funtion with delphi 7.
> This function is called RoundDouble
> Here is the function code.
> DD = ^Double;
> Function RoundDouble (X : DD; NDigit : PSmallInt) : Extended; Stdcall;
> Var A,Sayi,Tamsayi,Kusurat : Extended;
> Kusurat:=Sayi - Tamsayi;
> if (Kusurat <> 0) Then
> A:=Exp(NDigit^ * Ln(10));
> Kusurat:=Round(Kusurat * A) / A;
> Result:=Tamsayi + Kusurat;
> But this function is returns very sensitive numbers
> SELECT RoundDouble(1255521000.321313213,2),
> RoundDouble(1199392449.91999984,2) FROM RDB$DATABASE
> The result is that:
> but the result numbers are very sensitive
> the result must be
> what is the problem
> is this problem about firebird server
> i have tried another alternative but i can't find the solutions.
1. use the standard udf libary which will do the right thing - no need to do
it yourself, someone else has already invented this wheel.
2. return your result as a varchar (2 places) and then cast the result as a
double on the client.