Browse Source

* Add Ceil64 and Floor64, patch from Bart Broersma (bug ID 28370)

git-svn-id: trunk@32766 -
michael 9 years ago
parent
commit
88957c62e3
1 changed files with 16 additions and 0 deletions
  1. 16 0
      rtl/objpas/math.pp

+ 16 - 0
rtl/objpas/math.pp

@@ -364,8 +364,10 @@ operator ** (bas,expo : int64) i: int64; inline;
 
 
 { rounds x towards positive infinity }
 { rounds x towards positive infinity }
 function ceil(x : float) : Integer;
 function ceil(x : float) : Integer;
+function ceil64(x: float): Int64;
 { rounds x towards negative infinity }
 { rounds x towards negative infinity }
 function floor(x : float) : Integer;
 function floor(x : float) : Integer;
+function floor64(x: float): Int64;
 
 
 { misc. functions }
 { misc. functions }
 
 
@@ -1045,6 +1047,13 @@ function ceil(x : float) : integer;
       Ceil:=Ceil+1;
       Ceil:=Ceil+1;
   end;
   end;
 
 
+function ceil64(x: float): Int64;
+  begin
+    Ceil64:=Trunc(x);
+    if Frac(x)>0 then
+      Ceil64:=Ceil64+1;
+  end;
+
 function floor(x : float) : integer;
 function floor(x : float) : integer;
   begin
   begin
      Floor:=Trunc(x);
      Floor:=Trunc(x);
@@ -1052,6 +1061,13 @@ function floor(x : float) : integer;
        Floor := Floor-1;
        Floor := Floor-1;
   end;
   end;
 
 
+function floor64(x: float): Int64;
+  begin
+    Floor64:=Trunc(x);
+    if Frac(x)<0 then
+      Floor64:=Floor64-1;
+  end;
+
 
 
 procedure Frexp(X: float; var Mantissa: float; var Exponent: integer);
 procedure Frexp(X: float; var Mantissa: float; var Exponent: integer);
 begin
 begin