Unit msebits

Description

 

Overview

Classes, Interfaces, Objects and Records

Name Description
Record int64recty  

Functions and Procedures

function highestbit(value: longword): integer;
function lowestbit(value: longword): integer;
function nextpowerof2(const avalue: longword): longword;
function highestbit64(value: qword): integer;
function lowestbit64(value: qword): integer;
function replacebits(const new,old,mask: byte): byte; overload;
function replacebits(const new,old,mask: word): word; overload;
function replacebits(const new,old,mask: longword): longword; overload;
function replacebits1(var dest: byte; const value,mask: byte): boolean; overload;
function replacebits1(var dest: word; const value,mask: word): boolean; overload;
function replacebits1(var dest: longword; const value,mask: longword): boolean; overload;
function bitschanged(const a,b,mask: byte): boolean; overload;
function bitschanged(const a,b,mask: word): boolean; overload;
function bitschanged(const a,b,mask: longword): boolean; overload;
function setsinglebit(const new,old,mask: byte): byte; overload;
function setsinglebit(const new,old,mask: word): word; overload;
function setsinglebit(const new,old,mask: longword): longword; overload;
function setsinglebit(const new,old: byte; const mask: array of byte): byte; overload;
function setsinglebit(const new,old: word; const mask: array of word): word; overload;
function setsinglebit(const new,old: longword; const mask: array of longword): longword; overload;
function setsinglebitar8(const new,old: byte; const mask: array of byte): byte;
function setsinglebitar16(const new,old: word; const mask: array of word): word;
function setsinglebitar32(const new,old: longword; const mask: array of longword): longword;
function checkbit(const value: byte; const bitnum: integer): boolean; overload;
function checkbit(const value: word; const bitnum: integer): boolean; overload;
function checkbit(const value: longword; const bitnum: integer): boolean; overload;
function updatebit(var dest: byte; bitnum: integer; value: boolean): boolean; overload;
function updatebit(var dest: word; bitnum: integer; value: boolean): boolean; overload;
function updatebit(var dest: longword; bitnum: integer; value: boolean):boolean; overload;
procedure updatebit1(var dest: byte; bitnum: integer; value: boolean); overload;
procedure updatebit1(var dest: word; bitnum: integer; value: boolean); overload;
procedure updatebit1(var dest: longword; bitnum: integer; value: boolean); overload;
procedure setbit1(var dest: byte; bitnum: integer); overload;
procedure setbit1(var dest: word; bitnum: integer); overload;
procedure setbit1(var dest: longword; bitnum: integer); overload;
function setbit(const source: byte; bitnum: integer): byte; overload;
function setbit(const source: word; bitnum: integer): word; overload;
function setbit(const source: longword; bitnum: integer): longword; overload;
procedure clearbit1(var dest: byte; bitnum: integer); overload;
procedure clearbit1(var dest: word; bitnum: integer); overload;
procedure clearbit1(var dest: longword; bitnum: integer); overload;
function clearbit(const source: byte; bitnum: integer): byte; overload;
function clearbit(const source: word; bitnum: integer): word; overload;
function clearbit(const source: longword; bitnum: integer): longword; overload;
procedure togglebit1(var dest: byte; bitnum: integer); overload;
procedure togglebit1(var dest: word; bitnum: integer); overload;
procedure togglebit1(var dest: longword; bitnum: integer); overload;
function togglebit(const source: byte; bitnum: integer): byte; overload;
function togglebit(const source: word; bitnum: integer): word; overload;
function togglebit(const source: longword; bitnum: integer): longword; overload;
function iszero(address: pointer; count: integer): boolean;
function swapbytes(const value: word): word; overload;
function swapbytes(const value: longword): longword; overload;
procedure swapbytes1(var value: word); overload;
procedure swapbytes1(var value: longword); overload;
function swapbits(const value: word): word; overload;
function swapbits(const value: longword): longword; overload;
procedure swapbits1(var value: word); overload;
procedure swapbits1(var value: longword); overload;
procedure swaprgb1(var value: longword);
function swaprgb(const value: longword): longword;
function roundint(const value: integer; const step: integer): integer;
procedure scaleexp101(var value: int64; const exp: integer); overload;
procedure scaleexp101(var value: integer; const exp: integer); overload;
procedure scaleexp101(var value: currency; const exp: integer); overload;
function scaleexp10(const value: int64; const exp: integer): int64; overload;
function scaleexp10(const value: integer; const exp: integer): integer; overload;
function scaleexp10(const value: currency; const exp: integer): currency; overload;

Types

bitnumty = 0..32;

Constants

twoexp32 = flo64(4294967296.0);
bytebits: array[0..8] of byte = ($01,$02,$04,$08,$10,$20,$40,$80,$00);
bytemask: array[0..8] of byte = ($00,$01,$03,$07,$0f,$1f,$3f,$7f,$ff);
bytebitsreverse: array[0..8] of byte = ($80,$40,$20,$10,$08,$04,$02,$01,$00);
bits: array[bitnumty] of longword = ( $00000001,$00000002,$00000004,$00000008, $00000010,$00000020,$00000040,$00000080, $00000100,$00000200,$00000400,$00000800, $00001000,$00002000,$00004000,$00008000, $00010000,$00020000,$00040000,$00080000, $00100000,$00200000,$00400000,$00800000, $01000000,$02000000,$04000000,$08000000, $10000000,$20000000,$40000000,$80000000, $00000000);
bitmask: array[bitnumty] of longword = ( $00000000,$00000001,$00000003,$00000007, $0000000f,$0000001f,$0000003f,$0000007f, $000000ff,$000001ff,$000003ff,$000007ff, $00000fff,$00001fff,$00003fff,$00007fff, $0000ffff,$0001ffff,$0003ffff,$0007ffff, $000fffff,$001fffff,$003fffff,$007fffff, $00ffffff,$01ffffff,$03ffffff,$07ffffff, $0fffffff,$1fffffff,$3fffffff,$7fffffff, $ffffffff);
bitreverse: array[byte] of byte = ( $00,$80,$40,$c0,$20,$a0,$60,$e0,$10,$90,$50,$d0,$30,$b0,$70,$f0, $08,$88,$48,$c8,$28,$a8,$68,$e8,$18,$98,$58,$d8,$38,$b8,$78,$f8, $04,$84,$44,$c4,$24,$a4,$64,$e4,$14,$94,$54,$d4,$34,$b4,$74,$f4, $0c,$8c,$4c,$cc,$2c,$ac,$6c,$ec,$1c,$9c,$5c,$dc,$3c,$bc,$7c,$fc, $02,$82,$42,$c2,$22,$a2,$62,$e2,$12,$92,$52,$d2,$32,$b2,$72,$f2, $0a,$8a,$4a,$ca,$2a,$aa,$6a,$ea,$1a,$9a,$5a,$da,$3a,$ba,$7a,$fa, $06,$86,$46,$c6,$26,$a6,$66,$e6,$16,$96,$56,$d6,$36,$b6,$76,$f6, $0e,$8e,$4e,$ce,$2e,$ae,$6e,$ee,$1e,$9e,$5e,$de,$3e,$be,$7e,$fe, $01,$81,$41,$c1,$21,$a1,$61,$e1,$11,$91,$51,$d1,$31,$b1,$71,$f1, $09,$89,$49,$c9,$29,$a9,$69,$e9,$19,$99,$59,$d9,$39,$b9,$79,$f9, $05,$85,$45,$c5,$25,$a5,$65,$e5,$15,$95,$55,$d5,$35,$b5,$75,$f5, $0d,$8d,$4d,$cd,$2d,$ad,$6d,$ed,$1d,$9d,$5d,$dd,$3d,$bd,$7d,$fd, $03,$83,$43,$c3,$23,$a3,$63,$e3,$13,$93,$53,$d3,$33,$b3,$73,$f3, $0b,$8b,$4b,$cb,$2b,$ab,$6b,$eb,$1b,$9b,$5b,$db,$3b,$bb,$7b,$fb, $07,$87,$47,$c7,$27,$a7,$67,$e7,$17,$97,$57,$d7,$37,$b7,$77,$f7, $0f,$8f,$4f,$cf,$2f,$af,$6f,$ef,$1f,$9f,$5f,$df,$3f,$bf,$7f,$ff);
intexp10ar: array[0..9] of integer = (1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000);
int64exp10ar: array[0..19] of int64 = (1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000, 1000000000,10000000000,100000000000,1000000000000,10000000000000, 100000000000000,1000000000000000,10000000000000000, 100000000000000000,1000000000000000000);

Description

Functions and Procedures

function highestbit(value: longword): integer;
 
function lowestbit(value: longword): integer;
 
function nextpowerof2(const avalue: longword): longword;
 
function highestbit64(value: qword): integer;
 
function lowestbit64(value: qword): integer;
 
function replacebits(const new,old,mask: byte): byte; overload;
 
function replacebits(const new,old,mask: word): word; overload;
 
function replacebits(const new,old,mask: longword): longword; overload;
 
function replacebits1(var dest: byte; const value,mask: byte): boolean; overload;
 
function replacebits1(var dest: word; const value,mask: word): boolean; overload;
 
function replacebits1(var dest: longword; const value,mask: longword): boolean; overload;
 
function bitschanged(const a,b,mask: byte): boolean; overload;
 
function bitschanged(const a,b,mask: word): boolean; overload;
 
function bitschanged(const a,b,mask: longword): boolean; overload;
 
function setsinglebit(const new,old,mask: byte): byte; overload;
 
function setsinglebit(const new,old,mask: word): word; overload;
 
function setsinglebit(const new,old,mask: longword): longword; overload;
 
function setsinglebit(const new,old: byte; const mask: array of byte): byte; overload;
 
function setsinglebit(const new,old: word; const mask: array of word): word; overload;
 
function setsinglebit(const new,old: longword; const mask: array of longword): longword; overload;
 
function setsinglebitar8(const new,old: byte; const mask: array of byte): byte;
 
function setsinglebitar16(const new,old: word; const mask: array of word): word;
 
function setsinglebitar32(const new,old: longword; const mask: array of longword): longword;
 
function checkbit(const value: byte; const bitnum: integer): boolean; overload;
 
function checkbit(const value: word; const bitnum: integer): boolean; overload;
 
function checkbit(const value: longword; const bitnum: integer): boolean; overload;
 
function updatebit(var dest: byte; bitnum: integer; value: boolean): boolean; overload;
 
function updatebit(var dest: word; bitnum: integer; value: boolean): boolean; overload;
 
function updatebit(var dest: longword; bitnum: integer; value: boolean):boolean; overload;
 
procedure updatebit1(var dest: byte; bitnum: integer; value: boolean); overload;
 
procedure updatebit1(var dest: word; bitnum: integer; value: boolean); overload;
 
procedure updatebit1(var dest: longword; bitnum: integer; value: boolean); overload;
 
procedure setbit1(var dest: byte; bitnum: integer); overload;
 
procedure setbit1(var dest: word; bitnum: integer); overload;
 
procedure setbit1(var dest: longword; bitnum: integer); overload;
 
function setbit(const source: byte; bitnum: integer): byte; overload;
 
function setbit(const source: word; bitnum: integer): word; overload;
 
function setbit(const source: longword; bitnum: integer): longword; overload;
 
procedure clearbit1(var dest: byte; bitnum: integer); overload;
 
procedure clearbit1(var dest: word; bitnum: integer); overload;
 
procedure clearbit1(var dest: longword; bitnum: integer); overload;
 
function clearbit(const source: byte; bitnum: integer): byte; overload;
 
function clearbit(const source: word; bitnum: integer): word; overload;
 
function clearbit(const source: longword; bitnum: integer): longword; overload;
 
procedure togglebit1(var dest: byte; bitnum: integer); overload;
 
procedure togglebit1(var dest: word; bitnum: integer); overload;
 
procedure togglebit1(var dest: longword; bitnum: integer); overload;
 
function togglebit(const source: byte; bitnum: integer): byte; overload;
 
function togglebit(const source: word; bitnum: integer): word; overload;
 
function togglebit(const source: longword; bitnum: integer): longword; overload;
 
function iszero(address: pointer; count: integer): boolean;
 
function swapbytes(const value: word): word; overload;
 
function swapbytes(const value: longword): longword; overload;
 
procedure swapbytes1(var value: word); overload;
 
procedure swapbytes1(var value: longword); overload;
 
function swapbits(const value: word): word; overload;
 
function swapbits(const value: longword): longword; overload;
 
procedure swapbits1(var value: word); overload;
 
procedure swapbits1(var value: longword); overload;
 
procedure swaprgb1(var value: longword);
 
function swaprgb(const value: longword): longword;
 
function roundint(const value: integer; const step: integer): integer;
 
procedure scaleexp101(var value: int64; const exp: integer); overload;
 
procedure scaleexp101(var value: integer; const exp: integer); overload;
 
procedure scaleexp101(var value: currency; const exp: integer); overload;
 
function scaleexp10(const value: int64; const exp: integer): int64; overload;
 
function scaleexp10(const value: integer; const exp: integer): integer; overload;
 
function scaleexp10(const value: currency; const exp: integer): currency; overload;
 

Types

bitnumty = 0..32;
 

Constants

twoexp32 = flo64(4294967296.0);
 
bytebits: array[0..8] of byte = ($01,$02,$04,$08,$10,$20,$40,$80,$00);
 
bytemask: array[0..8] of byte = ($00,$01,$03,$07,$0f,$1f,$3f,$7f,$ff);
 
bytebitsreverse: array[0..8] of byte = ($80,$40,$20,$10,$08,$04,$02,$01,$00);
 
bits: array[bitnumty] of longword = ( $00000001,$00000002,$00000004,$00000008, $00000010,$00000020,$00000040,$00000080, $00000100,$00000200,$00000400,$00000800, $00001000,$00002000,$00004000,$00008000, $00010000,$00020000,$00040000,$00080000, $00100000,$00200000,$00400000,$00800000, $01000000,$02000000,$04000000,$08000000, $10000000,$20000000,$40000000,$80000000, $00000000);
 
bitmask: array[bitnumty] of longword = ( $00000000,$00000001,$00000003,$00000007, $0000000f,$0000001f,$0000003f,$0000007f, $000000ff,$000001ff,$000003ff,$000007ff, $00000fff,$00001fff,$00003fff,$00007fff, $0000ffff,$0001ffff,$0003ffff,$0007ffff, $000fffff,$001fffff,$003fffff,$007fffff, $00ffffff,$01ffffff,$03ffffff,$07ffffff, $0fffffff,$1fffffff,$3fffffff,$7fffffff, $ffffffff);
 
bitreverse: array[byte] of byte = ( $00,$80,$40,$c0,$20,$a0,$60,$e0,$10,$90,$50,$d0,$30,$b0,$70,$f0, $08,$88,$48,$c8,$28,$a8,$68,$e8,$18,$98,$58,$d8,$38,$b8,$78,$f8, $04,$84,$44,$c4,$24,$a4,$64,$e4,$14,$94,$54,$d4,$34,$b4,$74,$f4, $0c,$8c,$4c,$cc,$2c,$ac,$6c,$ec,$1c,$9c,$5c,$dc,$3c,$bc,$7c,$fc, $02,$82,$42,$c2,$22,$a2,$62,$e2,$12,$92,$52,$d2,$32,$b2,$72,$f2, $0a,$8a,$4a,$ca,$2a,$aa,$6a,$ea,$1a,$9a,$5a,$da,$3a,$ba,$7a,$fa, $06,$86,$46,$c6,$26,$a6,$66,$e6,$16,$96,$56,$d6,$36,$b6,$76,$f6, $0e,$8e,$4e,$ce,$2e,$ae,$6e,$ee,$1e,$9e,$5e,$de,$3e,$be,$7e,$fe, $01,$81,$41,$c1,$21,$a1,$61,$e1,$11,$91,$51,$d1,$31,$b1,$71,$f1, $09,$89,$49,$c9,$29,$a9,$69,$e9,$19,$99,$59,$d9,$39,$b9,$79,$f9, $05,$85,$45,$c5,$25,$a5,$65,$e5,$15,$95,$55,$d5,$35,$b5,$75,$f5, $0d,$8d,$4d,$cd,$2d,$ad,$6d,$ed,$1d,$9d,$5d,$dd,$3d,$bd,$7d,$fd, $03,$83,$43,$c3,$23,$a3,$63,$e3,$13,$93,$53,$d3,$33,$b3,$73,$f3, $0b,$8b,$4b,$cb,$2b,$ab,$6b,$eb,$1b,$9b,$5b,$db,$3b,$bb,$7b,$fb, $07,$87,$47,$c7,$27,$a7,$67,$e7,$17,$97,$57,$d7,$37,$b7,$77,$f7, $0f,$8f,$4f,$cf,$2f,$af,$6f,$ef,$1f,$9f,$5f,$df,$3f,$bf,$7f,$ff);
 
intexp10ar: array[0..9] of integer = (1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000);
 
int64exp10ar: array[0..19] of int64 = (1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000, 1000000000,10000000000,100000000000,1000000000000,10000000000000, 100000000000000,1000000000000000,10000000000000000, 100000000000000000,1000000000000000000);
 

Generated by PasDoc 0.16.0.