Subject Re: [IBO] Integer Overflow Exception
Author Helen Borrie
At 07:50 PM 14/03/2006, you wrote:

>The exact message is: 'Integerüberlauf' (which means: integer overflow),
>the exception class is EIntOverflow.
>
>
>- M.exe is my application,
>- TdmSaveLoad.GetAnzWerteMessdauer is a procedure which basically does
> execute the statement below:
> t1.messdauer is defined as double porecision

> and t1.abtastrate is an
> integer <------------------------------------------------------
>
> Stmt := 'select t1.MESSDAUER, t1.ABTASTRATE from t2 ' +
> 'join t1 on t1.SYS_PK = t2.FK_MESSUNG_1 ' +
> 'where t2.SYS_PK = ' + IntToStr (FK_Messung2);
>
> with qryTmp do begin
> Close;
> SQL.Clear;
> SQL.Text := Stmt;
> Open;
> if (EOF) then begin
> Messdauer := 0;
> AnzWerte := 0;
> end
> else begin
> Messdauer := FieldByName ('MESSDAUER').AsFloat;

> AnzWerte := Trunc (FieldByName ('ABTASTRATE').AsFloat * Messdauer);

Don't try to cast an integer as a float!

Should be
AnzWerte := Trunc(FieldByName ('ABTASTRATE').AsInteger * Messdauer);

or (if it is enough precision)
AnzWerte := FieldByName ('ABTASTRATE').AsInteger * Trunc(Messdauer);

But, if AnzWerte is declared as Integer (instead
of Extended) you *will* get an integer overflow,
if the calculation result exceeds the limit for
integer. Is this case possible for your data?

Helen