SameValue works incorrect
Original Reporter info from Mantis: and
-
Reporter name: Andrew G. Khodotov
Original Reporter info from Mantis: and
- Reporter name: Andrew G. Khodotov
Description:
WriteLn(SameValue(extended(1/1000),extended(1/2000))); //Writes "FALSE" - OK
WriteLn(SameValue(single(1/10000),single(1/20000))); //Writes "TRUE" - OK
WriteLn(SameValue(extended(1/10000),extended(1/20000))); //Writes "TRUE" - mistake
I think the trouble is in overloadind mechanism (or overloading + inline):
function SameValue(const A, B: Extended): Boolean;inline;
begin
Result:=SameValue(A,B,0);
end;
must call
function SameValue(const A, B: Extended; Epsilon: Extended): Boolean;
but really calls
function SameValue(const A, B: Single): Boolean;inline;
Moreover,
SameValue(extended(1/10000),extended(1/20000),0) calls SameValue(const A, B: Single)
SameValue(extended(1/10000),extended(1/20000),extended(0)) works properly.
Mantis conversion info:
- Mantis ID: 21199
- OS: Windows XP
- OS Build: SP3 rus
- Build: 20120131
- Platform: Win32
- Version: 2.7.1
- Fixed in version: 3.0.0
- Fixed in revision: 20461 (#ae1ece93)