Browse Source

+ Implemented DivMod

michael 21 years ago
parent
commit
5de50944d3
1 changed files with 17 additions and 1 deletions
  1. 17 1
      rtl/objpas/math.pp

+ 17 - 1
rtl/objpas/math.pp

@@ -171,6 +171,10 @@ function EnsureRange(const AValue, AMin, AMax: Int64): Int64;
 function EnsureRange(const AValue, AMin, AMax: Double): Double;
 {$endif FPC_HAS_TYPE_DOUBLE}
 
+
+procedure DivMod(Dividend: Integer; Divisor: Word;  var Result, Remainder: Word);
+  
+
 // Sign functions
 Type
   TValueSign = -1..1;
@@ -1321,11 +1325,23 @@ begin
     Result:=((B-A)<=Epsilon);
 end;
 
+// Some CPUs probably allow a faster way of doing this in a single operation...
+// There weshould define CPUDIVMOD in the header mathuh.inc and implement it using asm.
+{$ifndef CPUDIVMOD}
+procedure DivMod(Dividend: Integer; Divisor: Word;  var Result, Remainder: Word);
 
+begin
+  Result:=Dividend Div Divisor;
+  Remainder:=Dividend Mod Divisor;
+end;
+{$endif}
 end.
 {
   $Log$
-  Revision 1.22  2004-05-29 12:28:59  florian
+  Revision 1.23  2004-07-25 16:46:08  michael
+  + Implemented DivMod
+
+  Revision 1.22  2004/05/29 12:28:59  florian
     * fixed IsNan and IsInf for big endian systems
 
   Revision 1.21  2004/04/08 16:37:08  peter