mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 11:29:16 +02:00
* 16-bit objpas.integer type fixes in Math.DivMod
git-svn-id: trunk@27052 -
This commit is contained in:
parent
9bdbad0c39
commit
19a39cde4a
@ -151,10 +151,10 @@ function EnsureRange(const AValue, AMin, AMax: Double): Double;inline; overload
|
|||||||
{$endif FPC_HAS_TYPE_DOUBLE}
|
{$endif FPC_HAS_TYPE_DOUBLE}
|
||||||
|
|
||||||
|
|
||||||
procedure DivMod(Dividend: Integer; Divisor: Word; var Result, Remainder: Word);
|
procedure DivMod(Dividend: LongInt; Divisor: Word; var Result, Remainder: Word);
|
||||||
procedure DivMod(Dividend: Integer; Divisor: Word; var Result, Remainder: SmallInt);
|
procedure DivMod(Dividend: LongInt; Divisor: Word; var Result, Remainder: SmallInt);
|
||||||
procedure DivMod(Dividend: DWord; Divisor: DWord; var Result, Remainder: DWord);
|
procedure DivMod(Dividend: DWord; Divisor: DWord; var Result, Remainder: DWord);
|
||||||
procedure DivMod(Dividend: Integer; Divisor: Integer; var Result, Remainder: Integer);
|
procedure DivMod(Dividend: LongInt; Divisor: LongInt; var Result, Remainder: LongInt);
|
||||||
|
|
||||||
// Sign functions
|
// Sign functions
|
||||||
Type
|
Type
|
||||||
@ -2174,7 +2174,7 @@ end;
|
|||||||
// Some CPUs probably allow a faster way of doing this in a single operation...
|
// Some CPUs probably allow a faster way of doing this in a single operation...
|
||||||
// There weshould define FPC_MATH_HAS_CPUDIVMOD in the header mathuh.inc and implement it using asm.
|
// There weshould define FPC_MATH_HAS_CPUDIVMOD in the header mathuh.inc and implement it using asm.
|
||||||
{$ifndef FPC_MATH_HAS_DIVMOD}
|
{$ifndef FPC_MATH_HAS_DIVMOD}
|
||||||
procedure DivMod(Dividend: Integer; Divisor: Word; var Result, Remainder: Word);
|
procedure DivMod(Dividend: LongInt; Divisor: Word; var Result, Remainder: Word);
|
||||||
begin
|
begin
|
||||||
if Dividend < 0 then
|
if Dividend < 0 then
|
||||||
begin
|
begin
|
||||||
@ -2195,7 +2195,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure DivMod(Dividend: Integer; Divisor: Word; var Result, Remainder: SmallInt);
|
procedure DivMod(Dividend: LongInt; Divisor: Word; var Result, Remainder: SmallInt);
|
||||||
begin
|
begin
|
||||||
if Dividend < 0 then
|
if Dividend < 0 then
|
||||||
begin
|
begin
|
||||||
@ -2223,7 +2223,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure DivMod(Dividend: Integer; Divisor: Integer; var Result, Remainder: Integer);
|
procedure DivMod(Dividend: LongInt; Divisor: LongInt; var Result, Remainder: LongInt);
|
||||||
begin
|
begin
|
||||||
if Dividend < 0 then
|
if Dividend < 0 then
|
||||||
begin
|
begin
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
uses
|
uses
|
||||||
math;
|
math;
|
||||||
{ tests:
|
{ tests:
|
||||||
procedure DivMod(Dividend: Integer; Divisor: Word; var Result, Remainder: Word);
|
procedure DivMod(Dividend: LongInt; Divisor: Word; var Result, Remainder: Word);
|
||||||
procedure DivMod(Dividend: Integer; Divisor: Word; var Result, Remainder: SmallInt);
|
procedure DivMod(Dividend: LongInt; Divisor: Word; var Result, Remainder: SmallInt);
|
||||||
procedure DivMod(Dividend: DWord; Divisor: DWord; var Result, Remainder: DWord);
|
procedure DivMod(Dividend: DWord; Divisor: DWord; var Result, Remainder: DWord);
|
||||||
procedure DivMod(Dividend: Integer; Divisor: Integer; var Result, Remainder: Integer);
|
procedure DivMod(Dividend: LongInt; Divisor: LongInt; var Result, Remainder: LongInt);
|
||||||
}
|
}
|
||||||
procedure doerror(i : integer);
|
procedure doerror(i : LongInt);
|
||||||
begin
|
begin
|
||||||
writeln('Error: ',i);
|
writeln('Error: ',i);
|
||||||
halt(1);
|
halt(1);
|
||||||
@ -18,7 +18,7 @@ var
|
|||||||
QuotientWord,RemainderWord : Word;
|
QuotientWord,RemainderWord : Word;
|
||||||
QuotientSmallInt,RemainderSmallInt : SmallInt;
|
QuotientSmallInt,RemainderSmallInt : SmallInt;
|
||||||
QuotientDWord,RemainderDWord : DWord;
|
QuotientDWord,RemainderDWord : DWord;
|
||||||
QuotientInteger,RemainderInteger : Integer;
|
QuotientLongInt,RemainderLongInt : LongInt;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
DivMod($ffff,65,QuotientWord,RemainderWord);
|
DivMod($ffff,65,QuotientWord,RemainderWord);
|
||||||
@ -45,28 +45,28 @@ begin
|
|||||||
if RemainderDWord<>15 then
|
if RemainderDWord<>15 then
|
||||||
doerror(2004);
|
doerror(2004);
|
||||||
|
|
||||||
DivMod($ffff,65,QuotientInteger,RemainderInteger);
|
DivMod($ffff,65,QuotientLongInt,RemainderLongInt);
|
||||||
if QuotientInteger<>1008 then
|
if QuotientLongInt<>1008 then
|
||||||
doerror(3001);
|
doerror(3001);
|
||||||
if RemainderInteger<>15 then
|
if RemainderLongInt<>15 then
|
||||||
doerror(3002);
|
doerror(3002);
|
||||||
|
|
||||||
DivMod(123456,23,QuotientInteger,RemainderInteger);
|
DivMod(123456,23,QuotientLongInt,RemainderLongInt);
|
||||||
if QuotientInteger<>5367 then
|
if QuotientLongInt<>5367 then
|
||||||
doerror(3003);
|
doerror(3003);
|
||||||
if RemainderInteger<>15 then
|
if RemainderLongInt<>15 then
|
||||||
doerror(3004);
|
doerror(3004);
|
||||||
|
|
||||||
DivMod(-9, 5, QuotientInteger,RemainderInteger);
|
DivMod(-9, 5, QuotientLongInt,RemainderLongInt);
|
||||||
if QuotientInteger<>-1 then
|
if QuotientLongInt<>-1 then
|
||||||
doerror(3005);
|
doerror(3005);
|
||||||
if RemainderInteger<>-4 then
|
if RemainderLongInt<>-4 then
|
||||||
doerror(3006);
|
doerror(3006);
|
||||||
|
|
||||||
DivMod(-9, -5, QuotientInteger,RemainderInteger);
|
DivMod(-9, -5, QuotientLongInt,RemainderLongInt);
|
||||||
if QuotientInteger<>1 then
|
if QuotientLongInt<>1 then
|
||||||
doerror(3007);
|
doerror(3007);
|
||||||
if RemainderInteger<>-4 then
|
if RemainderLongInt<>-4 then
|
||||||
doerror(3008);
|
doerror(3008);
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user