Subject | Udf and Double Field |
---|---|
Author | ibrahim bulut |
Post date | 2004-11-04T13:42:31Z |
Hi,
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.
Type
DD = ^Double;
Function RoundDouble (X : DD; NDigit : PSmallInt) : Extended; Stdcall;
Var A,Sayi,Tamsayi,Kusurat : Extended;
Begin
Sayi:=X^;
Tamsayi:=Int(Sayi);
Kusurat:=Sayi - Tamsayi;
if (Kusurat <> 0) Then
Begin
A:=Exp(NDigit^ * Ln(10));
Kusurat:=Round(Kusurat * A) / A;
End;
Result:=Tamsayi + Kusurat;
End;
But this function is returns very sensitive numbers
Example
=======
SELECT RoundDouble(1255521000.321313213,2), RoundDouble(1199392449.91999984,2) FROM RDB$DATABASE
The result is that:
1255521000.31999993
1199392449.92000008
but the result numbers are very sensitive
the result must be
1255521000.32
1199392449.92
what is the problem
is this problem about firebird server
i have tried another alternative but i can't find the solutions.
Best Regards,
ibrahim Bulut
ileti�im Online Ltd.�ti.
Software and Database Expert
Turkish Republic
[Non-text portions of this message have been removed]
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.
Type
DD = ^Double;
Function RoundDouble (X : DD; NDigit : PSmallInt) : Extended; Stdcall;
Var A,Sayi,Tamsayi,Kusurat : Extended;
Begin
Sayi:=X^;
Tamsayi:=Int(Sayi);
Kusurat:=Sayi - Tamsayi;
if (Kusurat <> 0) Then
Begin
A:=Exp(NDigit^ * Ln(10));
Kusurat:=Round(Kusurat * A) / A;
End;
Result:=Tamsayi + Kusurat;
End;
But this function is returns very sensitive numbers
Example
=======
SELECT RoundDouble(1255521000.321313213,2), RoundDouble(1199392449.91999984,2) FROM RDB$DATABASE
The result is that:
1255521000.31999993
1199392449.92000008
but the result numbers are very sensitive
the result must be
1255521000.32
1199392449.92
what is the problem
is this problem about firebird server
i have tried another alternative but i can't find the solutions.
Best Regards,
ibrahim Bulut
ileti�im Online Ltd.�ti.
Software and Database Expert
Turkish Republic
[Non-text portions of this message have been removed]