[fpc-pascal] testing if a float has a fractional part

Bart bartjunk64 at gmail.com
Tue May 15 13:22:13 CEST 2018


On Sun, May 13, 2018 at 3:40 PM, Jonas Maebe <jonas at freepascal.org> wrote:
> The only proper way is to use something like Math.SameValue(x, int(x)).

B.t.w. the test suite for the new Int() function (win64)
(https://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/tests/tbs/tb0644.pp?view=markup)
uses

47 function SameValue(aGot, aExpected: Double): Boolean;
48 begin
49 if IsNan(aExpected) then
50 Result := IsNan(aGot)
51 else
52 Result := aGot = aExpected;
53 end;

Bart



More information about the fpc-pascal mailing list