Autor Beitrag
maxk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Fr 02.07.04 11:16 
Hallo,
ich hoffe ich habe jetzt die richtige Sparte erwischt. Es geht darum: Ein Boolean belegt theoretisch 0,125 Bytes Speicher. Aber ist das überhaupt möglich? Kann Windows jeweils 8 Boolean in einem Byte ablegen, oder wird für jedes Boolean ein neues Byte "verbraucht"?

Interessiert mich nur mal so...


Moderiert von user profile iconTino: Topic aus Sonstiges verschoben am Fr 02.07.2004 um 17:07

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.
MartinPb
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 698



BeitragVerfasst: Fr 02.07.04 11:23 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var
  B: Boolean;
begin
  ShowMessage(IntToStr(SizeOf( B )));
end;

_________________
Gruß
Martin
Muetze1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 346



BeitragVerfasst: Fr 02.07.04 12:09 
Moin!

LongBool, WordBool, ByteBool...

MfG
Muetze1
obbschtkuche
Gast
Erhaltene Danke: 1



BeitragVerfasst: Fr 02.07.04 15:15 
Es, geht, ist aber langsam.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
const
 bit1 = 1;
 bit2 = 2;
 bit3 = 4;
 bit4 = 8;
 bit5 = 16;
 bit6 = 32;
 bit7 = 64;
 bit8 = 128;

type
 mbool = byte;

var
 fbool: mbool;

// Jetzt kannst du bits setzen:

fbool := fbool or bit1; // Bit gesetzt

// Oder löschen

fbool := fbool and not bit1; // Bit gelöscht


Delphi benutzt immer ein byte, weil das einfach schneller geht
GlowWorm
Hält's aus hier
Beiträge: 9

Win 98 SE
D7 Entp
BeitragVerfasst: Sa 03.07.04 15:14 
Wenn du mehrere verwendest, kannst du auch einen "packed array of boolean" verwenden. Sollte eigentlich klappen. Aber ist natürlich langsamer. Ansonsten könnte ein boolean in einem Array auch 4 Byte einnehmen. (Alles nur AFAIK und IIRC)

_________________
Dies ist ein Text, der an jeden Beitrag von Dir angehängt werden kann. Es besteht eine Limit von 255 Buchstaben.
maxk Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1696
Erhaltene Danke: 1

Win XP, Debian Lenny
Delphi 6 Personal
BeitragVerfasst: Mo 05.07.04 09:55 
Nagut, danke für die Antworten. Wenn es eine solche Speicherrumschleudereu in Zeiten der Lochkarten gegeben hätte...

_________________
Ein Computer wird das tun, was Du programmierst - nicht das, was Du willst.