[fpc-pascal] Crash in Math.SameValue()
Bart
bartjunk64 at gmail.com
Fri Dec 22 16:03:08 CET 2017
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
More information about the fpc-pascal
mailing list