Changeset 434 for Common/UCommon.pas
- Timestamp:
- Nov 19, 2012, 2:31:00 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/UCommon.pas
r404 r434 48 48 function LoggedOnUserNameEx(Format: TUserNameFormat): string; 49 49 function SplitString(var Text: string; Count: Word): string; 50 function GetBitCount(Variable: QWord; MaxIndex: Integer): Integer; 50 51 function GetBit(Variable: QWord; Index: Byte): Boolean; 52 procedure SetBit(var Variable: Int64; Index: Byte; State: Boolean); overload; 51 53 procedure SetBit(var Variable: QWord; Index: Byte; State: Boolean); overload; 52 54 procedure SetBit(var Variable: Cardinal; Index: Byte; State: Boolean); overload; … … 336 338 end; 337 339 340 function GetBitCount(Variable: QWord; MaxIndex: Integer): Integer; 341 var 342 I: Integer; 343 begin 344 Result := 0; 345 for I := 0 to MaxIndex - 1 do 346 if ((Variable shr I) and 1) = 1 then Inc(Result); 347 end; 348 338 349 function GetBit(Variable:QWord;Index:Byte):Boolean; 339 350 begin … … 341 352 end; 342 353 354 procedure SetBit(var Variable: Int64; Index: Byte; State: Boolean); 355 begin 356 Variable := (Variable and ((1 shl Index) xor High(QWord))) or (Int64(State) shl Index); 357 end; 358 343 359 procedure SetBit(var Variable:QWord;Index:Byte;State:Boolean); overload; 344 360 begin 345 Variable := (Variable and ((1 shl Index) xor QWord($ffffffffffffffff))) or (QWord(State) shl Index);361 Variable := (Variable and ((1 shl Index) xor High(QWord))) or (QWord(State) shl Index); 346 362 end; 347 363 348 364 procedure SetBit(var Variable:Cardinal;Index:Byte;State:Boolean); overload; 349 365 begin 350 Variable := (Variable and ((1 shl Index) xor Cardinal($ffffffff))) or (Cardinal(State) shl Index);366 Variable := (Variable and ((1 shl Index) xor High(Cardinal))) or (Cardinal(State) shl Index); 351 367 end; 352 368 353 369 procedure SetBit(var Variable:Word;Index:Byte;State:Boolean); overload; 354 370 begin 355 Variable := (Variable and ((1 shl Index) xor Word($ffff))) or (Word(State) shl Index);371 Variable := (Variable and ((1 shl Index) xor High(Word))) or (Word(State) shl Index); 356 372 end; 357 373
Note:
See TracChangeset
for help on using the changeset viewer.