Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Bits to Byte? (https://www.delphipraxis.net/93348-bits-byte.html)

NikoMitDaMacht 4. Jun 2007 17:09


Bits to Byte?
 
Hi !
Auch wenn die Frage etwas,nun ja, blööd ist stell ich sie trozdem:

Wie kann ich ein 8 stelliges array von booleans zu einem Byte zuammenfügen?

Dax 4. Jun 2007 17:12

Re: Bits to Byte?
 
Das sollte einfach sein.
Delphi-Quellcode:
var bits: array[0..7] of boolean;
  b: byte;
  i: integer;
const
  bit: array[boolean] of byte = (0, 1);

b := 0;
for i := 0 to 7 do
  b := b shl 1 or bit[bits[i]];

NikoMitDaMacht 4. Jun 2007 17:15

Re: Bits to Byte?
 
Super danke! :thumb:


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:54 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz