|
@@ -26,6 +26,9 @@ unit cutils;
|
|
|
|
|
|
interface
|
|
interface
|
|
|
|
|
|
|
|
+uses
|
|
|
|
+ cpuinfo;
|
|
|
|
+
|
|
{$ifdef delphi}
|
|
{$ifdef delphi}
|
|
type
|
|
type
|
|
dword = cardinal;
|
|
dword = cardinal;
|
|
@@ -57,7 +60,7 @@ interface
|
|
function tostr_with_plus(i : longint) : string;
|
|
function tostr_with_plus(i : longint) : string;
|
|
procedure valint(S : string;var V : longint;var code : integer);
|
|
procedure valint(S : string;var V : longint;var code : integer);
|
|
function is_number(const s : string) : boolean;
|
|
function is_number(const s : string) : boolean;
|
|
- function ispowerof2(value : longint;var power : longint) : boolean;
|
|
|
|
|
|
+ function ispowerof2(value : TConstExprInt;var power : longint) : boolean;
|
|
function maybequoted(const s:string):string;
|
|
function maybequoted(const s:string):string;
|
|
function CompareText(S1, S2: string): longint;
|
|
function CompareText(S1, S2: string): longint;
|
|
|
|
|
|
@@ -479,17 +482,22 @@ uses
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
- function ispowerof2(value : longint;var power : longint) : boolean;
|
|
|
|
|
|
+ function ispowerof2(value : TConstExprInt;var power : longint) : boolean;
|
|
{
|
|
{
|
|
return if value is a power of 2. And if correct return the power
|
|
return if value is a power of 2. And if correct return the power
|
|
}
|
|
}
|
|
var
|
|
var
|
|
- hl : longint;
|
|
|
|
|
|
+ hl : TConstExprInt;
|
|
i : longint;
|
|
i : longint;
|
|
begin
|
|
begin
|
|
|
|
+ if value and (value - 1) <> 0 then
|
|
|
|
+ begin
|
|
|
|
+ ispowerof2 := false;
|
|
|
|
+ exit
|
|
|
|
+ end;
|
|
hl:=1;
|
|
hl:=1;
|
|
ispowerof2:=true;
|
|
ispowerof2:=true;
|
|
- for i:=0 to 31 do
|
|
|
|
|
|
+ for i:=0 to 63 do
|
|
begin
|
|
begin
|
|
if hl=value then
|
|
if hl=value then
|
|
begin
|
|
begin
|
|
@@ -748,7 +756,10 @@ initialization
|
|
end.
|
|
end.
|
|
{
|
|
{
|
|
$Log$
|
|
$Log$
|
|
- Revision 1.10 2001-08-04 11:06:30 peter
|
|
|
|
|
|
+ Revision 1.11 2001-09-05 15:20:26 jonas
|
|
|
|
+ * ispowerf2 now works with 64bit ints and should be faster
|
|
|
|
+
|
|
|
|
+ Revision 1.10 2001/08/04 11:06:30 peter
|
|
* browcol has no depends on ide/fv
|
|
* browcol has no depends on ide/fv
|
|
|
|
|
|
Revision 1.9 2001/07/30 20:59:27 peter
|
|
Revision 1.9 2001/07/30 20:59:27 peter
|