Subject Re: [IBO] Rounding problem
Author Daniel Rail

At April 20, 2005, 04:32, Geoff Worboys wrote:

>>> It seems likely to me that we are dealing with a field that is
>>> represented as a floating point. I have never really studied
>>> the AVG code to see what type it returns under various
>>> conditions. I suspect that the problem may be that TIB_Query
>>> is looking at the data type (NUMERIC(15,2)) and treating it as
>>> a scaled integer - whereas TIBOQuery is reading it as a
>>> floating point.

>> TIBOQuery reads it as a BCD, not as a floating point.

> Daniel,

> Where are you taking that from? (Experiment or assumption?)

Experiment and database was created using Dialect 3.

> In the GetDataTypeAndSize function in IBODataset.pas there is
> this code:

> if SQLScale <> 0 then
> begin
> NewDataType := ftFloat;
> case SQLType of
> else
> if IsCurrencyDataType then
> begin
> NewDataType := ftBCD;
> NewDataSize := -SQLScale;
> end;
> end;

I thought because I was using a CURRENCY domain name for the field,
that it might be caught by IsCurrencyDataType. But, I have other
fields that are defined directly as NUMERIC(15,2) and Numeric(9,4),
and those two types get declared as TBCDField.

> Notice that an SQLType of float or double will result in the
> NewDataType being returned as ftFloat.

But, also if you look further down in that same method's code, that if
an attribute of BCD was assigned to the field, ftFloat is changed to

> If the database is dialect 1 (or was upgraded from dialect 1)
> then the underlying SQLType is probably double. So it appears
> to me that such instances will result in iboquery with ftFloat.

> Disclaimer: I have not setup any experiments to test all this.
> Just passing on my guesstimate that dialect 1 vs dialect 3
> issues could be confusing this situation. Hence the request
> for more information.

At the moment, Riho is the only person to be able to confirm if in the
application the field is declared as TFloatField or TBCDField.

Best regards,
Daniel Rail
Senior System Engineer
ACCRA Group Inc. (
ACCRA Med Software Inc. (