Udf error : Floating-Point invalid operand

Interbase(5.5), delphi 4

hello,

I had writen a UDF to round a numeric(15,2) interbase field  to X decimals

/*  Function ARRONDIDEV  */
DECLARE EXTERNAL FUNCTION ARRONDIDEV
   DOUBLE PRECISION, INTEGER
   RETURNS DOUBLE PRECISION BY VALUE
  ENTRY_POINT "arrondidev"  MODULE_NAME "ppkib1.dll"

this function work fine in many case ...but sometimes it's tell me
'Floating-Point invalid operand'.

look at my source code:

function ArrondiDevise(var Value: Double; var Decimales: Integer): Double;
var
 xFrac: Double;
 xInt: Int64;
 ii, signe: Integer;
begin
  // le signe
  if (Abs(Value) = Value) then
    signe := 1
  else
    signe := -1;
  Value := Abs(Value);

  // sparation des parties entire et dcimale
  xInt := Trunc(Value);
  xFrac := (Value - Trunc(Value));

  // arrondi de la partie dcimale
  if (xFrac <> 0.0) then
  begin
    ii := 1;
    while ((xFrac - Trunc(xFrac)) <> 0.0) and (ii <= Decimales) and (ii <
15) do
    begin
      xFrac := xFrac * 10;
      Inc(ii);
    end;
    if ((xFrac - Trunc(xFrac)) >= 0.5) then
      xFrac := xFrac + 1;
    xFrac := Trunc(xFrac);
    for ii := 1 to Decimales do
      xFrac := xFrac / 10;
    Result := xInt + xFrac;
  end
  else // on a pass un entier
  begin
    Result := xInt;
  end;
  Result := signe * Result;
end;

I think it's because i have too big values in my database (ex:
0.97999999999999999)

if it's the case, do you know the way to prevent this errors in a UDF ?

Thanks for any help.

Julien