![]() |
Re: bit <---> word
ahh ... cool danke :)
Die SHL-functionen von DAX gefallen mir aber die BitsToInt scheint nicht zu klappen :gruebel: EDIT: ahh .. wenn ich die bit's umdrehe dann klapps (31=0, 30=1,...)
Delphi-Quellcode:
habs einfach so gemach .. dann klappts wieder ^^
for i := High(Bits) downto 0 do
jetzt nur noch rausfinden warum's überhaupt geht :gruebel: |
Re: bit <---> word
Zitat:
Delphi-Quellcode:
Gruß Hagen
begin
Result := 0; for i := Low(Bits) to High(Bits) do Inc(Result, Result + Ord(Bits[i])); end; |
Re: bit <---> word
hier meine ^^ (die versteh ich sogar !!)
Delphi-Quellcode:
Dank shl ganz ohne power(2,y), trunc, div & mod !!
function TForm1.BitToWord(bits:TBitArray):Word;
var i : Integer; begin result := 0; for i := low(bits) to high(bits) do if bits[i] then result := result + (1 shl i); end; function TForm1.WordToBit(eingang:Word): TBitArray; var m,i : integer; begin for i := 15 downto 0 do begin m:= 1 shl i; if eingang >= m then begin result[i] := true; eingang := eingang-m; end else result[i] := false; end end; |
Re: bit <---> word
Dank himitsu's
![]()
Delphi-Quellcode:
type TBitArray = array[0..15] of boolean;
... function WordToBit(Eingang:Word): TBitArray; var i : integer; begin for i := 0 to 15 do Result[i] := (Eingang shr i) and 1 <> 0; end; |
Re: bit <---> word
JCL to the rescue! JclLogic.pas hat alles was du brauchst und noch viel mehr.
|
DP-Maintenance
Dieses Thema wurde von "Matze" von "Programmieren allgemein" nach "Sonstige Fragen zu Delphi" verschoben.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:30 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz