Subject Invalid floating point operation in IBODataset.pas
Author IMB T
Hi,

When I try to post a value of 20.000.000 in a NUMERIC(15, 4) field I receive
'Invalid floating point operation' error.

I use IBO 4.2m, D6, IB6.0.1.6, WinXP, Athlon ~900MHz.
AFAIK, this problem appeared also in the older versions, but for a period it
dissapeared.
The code:

procedure TIBODataset.InternalSetFieldData( Field: TField; Buffer:
Pointer );
...
function _TrimExt( e: extended ): extended;
const
CorrFactor: Longint = 100000000;
CW: word = $1332; //same as system.Default8087CW
var
PlaceFor64Bit: packed array [0..1] of longint;
asm
fldcw word ptr [CW] //reset control word if modified to default
fld tbyte ptr [e] //load function param to ST
fimul dword ptr [CorrFactor] //mult ST with CorrFactor, result stored in
ST
fistp qword ptr [PlaceFor64Bit]//int store with rnd rslt to PFor64Bit &
clr ST

fwait // <----------- here throws 'Invalid floating point op'

fild qword ptr [PlaceFor64Bit] //load integer result of fmul into ST
fidiv dword ptr [CorrFactor] //divide by CorrFactor, result stored in ST
fstp tbyte ptr [Result] //store result into funtions Result and clear
ST
fwait
end;

The fix (at least for me):

I changed the CorrFactor to 1000000 and it works. (Tested also with
200.000.000)
But, if the Jason wants, perhaps can explain to me what he wants to do here,
or, at least, to tell me if this quick fix works for all situations.

HTH