Crash in Math.SameValue()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Crash in Math.SameValue()

Bart-48
 Hi,

If you are unlucky enought to use TExtendedHelper.BuildUP() with wrong
values for Mantissa and Exponent, you end up with a binary pattern
that does not represent a valid floating point value.

(Yes, this is a programmer's error)

Now if you supply this "illegal" float as a parameter to
Math.SameValue(), this function will crash.

Example:

uses Math;

var
  E1, E2: Extended;
  B: Boolean;

begin
  E1 := E1.BuildUp(False, 0, 16383);
  E2 := 1.0;
  B := SameValue(E2, E1); // EInvalidOp: Invalid floating point operation
end.


Is that expected (as in: documented) behaviour?
Does Delphi do the same (I cannot test myself)?

B.t.w.:

writeln(E2); // gives 'NaN';
writeln(IsNas(E2)); //gives FALSE

Bart
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal