mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 23:21:57 +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}
|
||||
|
||||
|
||||
procedure DivMod(Dividend: Integer; 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: Word);
|
||||
procedure DivMod(Dividend: LongInt; Divisor: Word; var Result, Remainder: SmallInt);
|
||||
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
|
||||
Type
|
||||
@ -2174,7 +2174,7 @@ end;
|
||||
// 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.
|
||||
{$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
|
||||
if Dividend < 0 then
|
||||
begin
|
||||
@ -2195,7 +2195,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure DivMod(Dividend: Integer; Divisor: Word; var Result, Remainder: SmallInt);
|
||||
procedure DivMod(Dividend: LongInt; Divisor: Word; var Result, Remainder: SmallInt);
|
||||
begin
|
||||
if Dividend < 0 then
|
||||
begin
|
||||
@ -2223,7 +2223,7 @@ begin
|
||||
end;
|
||||
|
||||
|
||||
procedure DivMod(Dividend: Integer; Divisor: Integer; var Result, Remainder: Integer);
|
||||
procedure DivMod(Dividend: LongInt; Divisor: LongInt; var Result, Remainder: LongInt);
|
||||
begin
|
||||
if Dividend < 0 then
|
||||
begin
|
||||
|
@ -2,12 +2,12 @@
|
||||
uses
|
||||
math;
|
||||
{ tests:
|
||||
procedure DivMod(Dividend: Integer; 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: Word);
|
||||
procedure DivMod(Dividend: LongInt; Divisor: Word; var Result, Remainder: SmallInt);
|
||||
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
|
||||
writeln('Error: ',i);
|
||||
halt(1);
|
||||
@ -18,7 +18,7 @@ var
|
||||
QuotientWord,RemainderWord : Word;
|
||||
QuotientSmallInt,RemainderSmallInt : SmallInt;
|
||||
QuotientDWord,RemainderDWord : DWord;
|
||||
QuotientInteger,RemainderInteger : Integer;
|
||||
QuotientLongInt,RemainderLongInt : LongInt;
|
||||
|
||||
begin
|
||||
DivMod($ffff,65,QuotientWord,RemainderWord);
|
||||
@ -45,28 +45,28 @@ begin
|
||||
if RemainderDWord<>15 then
|
||||
doerror(2004);
|
||||
|
||||
DivMod($ffff,65,QuotientInteger,RemainderInteger);
|
||||
if QuotientInteger<>1008 then
|
||||
DivMod($ffff,65,QuotientLongInt,RemainderLongInt);
|
||||
if QuotientLongInt<>1008 then
|
||||
doerror(3001);
|
||||
if RemainderInteger<>15 then
|
||||
if RemainderLongInt<>15 then
|
||||
doerror(3002);
|
||||
|
||||
DivMod(123456,23,QuotientInteger,RemainderInteger);
|
||||
if QuotientInteger<>5367 then
|
||||
DivMod(123456,23,QuotientLongInt,RemainderLongInt);
|
||||
if QuotientLongInt<>5367 then
|
||||
doerror(3003);
|
||||
if RemainderInteger<>15 then
|
||||
if RemainderLongInt<>15 then
|
||||
doerror(3004);
|
||||
|
||||
DivMod(-9, 5, QuotientInteger,RemainderInteger);
|
||||
if QuotientInteger<>-1 then
|
||||
DivMod(-9, 5, QuotientLongInt,RemainderLongInt);
|
||||
if QuotientLongInt<>-1 then
|
||||
doerror(3005);
|
||||
if RemainderInteger<>-4 then
|
||||
if RemainderLongInt<>-4 then
|
||||
doerror(3006);
|
||||
|
||||
DivMod(-9, -5, QuotientInteger,RemainderInteger);
|
||||
if QuotientInteger<>1 then
|
||||
DivMod(-9, -5, QuotientLongInt,RemainderLongInt);
|
||||
if QuotientLongInt<>1 then
|
||||
doerror(3007);
|
||||
if RemainderInteger<>-4 then
|
||||
if RemainderLongInt<>-4 then
|
||||
doerror(3008);
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user