* float version of modulo (Patch from Thaddy De koning, bug ID #30744)

git-svn-id: trunk@34968 -
This commit is contained in:
michael 2016-11-26 16:57:34 +00:00
parent ba35278552
commit 18f2592433

View File

@ -192,6 +192,21 @@ procedure DivMod(Dividend: LongInt; Divisor: Word; var Result, Remainder: SmallI
procedure DivMod(Dividend: DWord; Divisor: DWord; var Result, Remainder: DWord);
procedure DivMod(Dividend: LongInt; Divisor: LongInt; var Result, Remainder: LongInt);
{ Floating point modulo}
{$ifdef FPC_HAS_TYPE_SINGLE}
function FMod(const a, b: Single): Single;inline;overload;
{$endif FPC_HAS_TYPE_SINGLE}
{$ifdef FPC_HAS_TYPE_DOUBLE}
function FMod(const a, b: Double): Double;inline;overload;
{$endif FPC_HAS_TYPE_DOUBLE}
{$ifdef FPC_HAS_TYPE_EXTENDED}
function FMod(const a, b: Extended): Extended;inline;overload;
{$endif FPC_HAS_TYPE_EXTENDED}
operator mod(const a,b:float) c:float;inline;
// Sign functions
Type
TValueSign = -1..1;
@ -2380,6 +2395,32 @@ begin
end;
{$endif FPC_MATH_HAS_DIVMOD}
{ Floating point modulo}
{$ifdef FPC_HAS_TYPE_SINGLE}
function FMod(const a, b: Single): Single;inline;overload;
begin
result:= a-b * trunc(a/b);
end;
{$endif FPC_HAS_TYPE_SINGLE}
{$ifdef FPC_HAS_TYPE_DOUBLE}
function FMod(const a, b: Double): Double;inline;overload;
begin
result:= a-b * trunc(a/b);
end;
{$endif FPC_HAS_TYPE_DOUBLE}
{$ifdef FPC_HAS_TYPE_EXTENDED}
function FMod(const a, b: Extended): Extended;inline;overload;
begin
result:= a-b * trunc(a/b);
end;
{$endif FPC_HAS_TYPE_EXTENDED}
operator mod(const a,b:float) c:float;inline;
begin
c:= a-b * trunc(a/b);
end;
function ifthen(val:boolean;const iftrue:integer; const iffalse:integer= 0) :integer;
begin