-3

I am using TFDTable component in Delphi Seattle. I have kept this table component at design time.

While executing TFDTable(Compo).Open

I get error while debugging (Ctrl +F7) "Floating point inexact result at 0042F353"

I googled, but got the reason but didn't get exactly what it is.

Any suggestions?

Reference URL:

http://www.delphigroups.info/2/e8/524771.html

Floating Point inexact result

This exception suggests that you have the "loss of precision" mask bit in the FPU turned OFF. It is normally ON. Look for the $0020 bit in the system variable Default8087CW and try ORing in $0020 into the control word with a Set8087CW(Default8087CW or $0020) statement.

http://www.umiacs.umd.edu/~resnik/ling645_sp2002/cmu_manual/node19.html

Community
  • 1
  • 1
Vishal Tiwari
  • 739
  • 2
  • 12
  • 28
  • What exactly is it that you do not get? Please, be more specific and copy - paste the relevant lines you want to refer to (keep the source link though). Without the relevant text here, your question might become worthless for future readers. IMO, the text I *believe* you refer to states clearly what it is about. – Tom Brunberg May 03 '16 at 06:51
  • What driver are you using? What is the nature of the data that you're returning? Do you get that error for any table or just for a specific one? Have you tried opening a copy of that table but without any data? The problem may be the driver, an unsupported feature in the table you're attempting to open, or a value in the table that is processing incorrectly. – Ezequiel Tolnay May 03 '16 at 08:05
  • You need to show some real code in your q with sufficient detail to enable readers to reproduce your problem if you want any help. TFDTable(Compo).Open obviously isn't real code. – MartynA May 03 '16 at 10:45
  • @MartynA: Sorry for delay in reply. There a table which has only less than 20 rows with one numeric column and there are other columns as well with other data type. – Vishal Tiwari May 04 '16 at 10:22
  • @Tom: I am not getting this point, "> then as "Floating Point inexact result -> This exception suggests that you have the "loss of precision" mask bit in the FPU turned OFF. It is normally ON. Look for the $0020 bit in the system variable Default8087CW and try ORing in $0020 into the control word with a Set8087CW(Default8087CW or $0020) statement. " – Vishal Tiwari May 04 '16 at 10:25

1 Answers1

1

There is a well known issue that Default8087CW as a global variable can be misused by libraries or even your own code and be changed at any time in ways that cause unexpected results of FP calculations or unexpected exceptions to occur. The six lowest bits of the 8087 FPU Control word are the exception mask bits, meaning that if a bit is set, corresponding exception is masked, that is prevented from being raised.

The "loss of precision" mask bit that John Herbster is talking about is one of those bits, in Delphis TArithmeticException enum called exPrecision. Further he suggests to assure this bit is set by calling the Set8087CW(Default8087CW or $0020). Since you are using Delphi 10 Seattle, it is recommended to use the SetExceptionMask() function (from the System.Math unit) instead, since it handles equally also the corresponding SSE mask on 64 bit hw:

var
  OldExceptionMask: TArithmeticExceptionMask;
...
OldExceptionMask := SetExceptionMask(GetExceptionMask + [exPrecision]);

Calling the above before TFDTable(Compo).Open should solve your problem.

The function takes and returns a TArithmeticExceptionMask (set of TArithmeticException). All other exception enums and FPU/SSE related functions are in the documentation.

Tom Brunberg
  • 20,312
  • 8
  • 37
  • 54