Subject | Re: [IBO] Integer Overflow Exception |
---|---|
Author | Robert Wagner |
Post date | 2006-03-14T15:40:30Z |
Hi Helen,
Helen Borrie schrieb:
The field ABTASTRATE contains always the value 200.000 and MESSDAUER
contains a value between 1 and 5 so that the variable Anzwerte ist
always between 200.000 and 1.000.000.
I had other cases where the integer overflow occured and in those cases
the procedure GetAnzWerteMessdauer was not called.
Common to all exception cases is that the exception occurs in line
3242 in unit IBODataSet.InternalGetFieldData at the following statement:
tmpData := pointer( longint( ARecBuf ) +
longint( SQLData ) -
longint( InternalDataset.Fields.RowBuffer ));
Meanwhile I uninstalled IBO 4.6.A and installed 4.5.B.
And guess what happended: The exception seems to be gone.
Do you (or Jason?) have an idea, what's the difference between this two
IBO versions and what could cause the integer overflow exception in IBO
4.6.A?
Thanks for any hints
Robert Wagner
Helen Borrie schrieb:
>I don't think that this is the cause of the exception.
> 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
The field ABTASTRATE contains always the value 200.000 and MESSDAUER
contains a value between 1 and 5 so that the variable Anzwerte ist
always between 200.000 and 1.000.000.
I had other cases where the integer overflow occured and in those cases
the procedure GetAnzWerteMessdauer was not called.
Common to all exception cases is that the exception occurs in line
3242 in unit IBODataSet.InternalGetFieldData at the following statement:
tmpData := pointer( longint( ARecBuf ) +
longint( SQLData ) -
longint( InternalDataset.Fields.RowBuffer ));
Meanwhile I uninstalled IBO 4.6.A and installed 4.5.B.
And guess what happended: The exception seems to be gone.
Do you (or Jason?) have an idea, what's the difference between this two
IBO versions and what could cause the integer overflow exception in IBO
4.6.A?
Thanks for any hints
Robert Wagner